Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pr susulan : peta wilayah #423

Merged
merged 3 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
204 changes: 110 additions & 94 deletions resources/views/data/data_umum/edit.blade.php
Original file line number Diff line number Diff line change
@@ -1,70 +1,101 @@
@extends('layouts.dashboard_template')

@section('content')
<section class="content-header">
<h1>
{{ $page_title ?? "Page Title" }}
<small>{{ $page_description ?? '' }}</small>
</h1>
<ol class="breadcrumb">
<li><a href="{{ route('dashboard') }}"><i class="fa fa-dashboard"></i> Dashboard</a></li>
<li class="active">Data Umum</a></li>
</ol>
</section>
<section class="content-header">
<h1>
{{ $page_title ?? 'Page Title' }}
<small>{{ $page_description ?? '' }}</small>
</h1>
<ol class="breadcrumb">
<li><a href="{{ route('dashboard') }}"><i class="fa fa-dashboard"></i> Dashboard</a></li>
<li class="active">Data Umum</a></li>
</ol>
</section>

<section class="content container-fluid">
<section class="content container-fluid">

@include( 'partials.flash_message' )
@include('partials.flash_message')

<div class="box box-primary">
{!! Form::model($data_umum, ['route' => ['data.data-umum.update', $data_umum->id], 'method' => 'put', 'id' => 'form-event', 'class' => 'form-horizontal form-label-left']) !!}

@if(count($errors) > 0)
<input type="hidden" name="path" id="path" value="{{ $data_umum->path }}">

<div class="alert alert-danger">
<strong>Ups!</strong> Ada beberapa masalah dengan masukan Anda.<br><br>
<ul>
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
<div class="nav-tabs-custom">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#wilayah" role="tab" aria-controls="wilayah"
data-toggle="tab">Info Wilyah</a></li>
<li role="presentation"><a href="#peta" role="tab" aria-controls="peta" data-toggle="tab">Peta Wilayah</a>
</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="wilayah">
<div class="box-body">
@include('data.data_umum.form_edit')
</div>
</div>

<div role="tabpanel" class="tab-pane" id="peta">
<div class="row">
<div class="col-sm-12">
<div id="tampil-map" style="height:500px">
<div class="text-center" style="margin-top: 35vh">
<h1>Memuat Peta</h1>
</div>
</div>
</div>
</div>
</div>
</div>

@endif

<!-- form start -->
{!! Form::model($data_umum, [ 'route' => ['data.data-umum.update', $data_umum->id], 'method' => 'put','id' =>
'form-event', 'class' => 'form-horizontal form-label-left' ] ) !!}
<input type="hidden" name="path" id="path" value="{{ $data_umum->path }}">

<div class="box-body">
@include('data.data_umum.form_edit')
</div>
<!-- /.box-body -->
<div class="box-footer">
<div class="pull-right">
<div class="control-group">
<a href="{{ route('data.data-umum.index') }}">
<button type="button" class="btn btn-default btn-sm"><i class="fa fa-refresh"></i>&nbsp;
Batal</button>
</a>
<button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-save"></i>&nbsp;
Simpan</button>
<div class="box-footer">
<div class="pull-right">
<div class="control-group">
<a href="{{ route('data.data-umum.index') }}">
<button type="button" class="btn btn-default btn-sm"><i class="fa fa-refresh"></i>&nbsp;
Batal</button>
</a>
<button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-save"></i>&nbsp;
Simpan</button>
</div>
</div>
</div>
</div>
{!! Form::close() !!}

</div>
</section>
{!! Form::close() !!}
</section>
@endsection

@include('partials.asset_wysihtml5')
@include(('partials.asset_select2'))
@include(('partials.asset_leaflet'))
@include('partials.asset_select2')
@include('partials.asset_leaflet')
@push('scripts')
<script>
$(function () {
$(function() {
$('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
if (e.target.hash == '#peta') {
$.when(path_desa()).done(function(res_desa) {
if (res_desa) {
var marker_desa = new Array();
var marker;
res_desa.data.forEach(e => {
if (e.path != null) {
marker = set_marker(e, 'Peta Wilayah Desa',
'Wilayah Desa ' + e
.nama, {
'line': '#de2d26',
'fill': '#fff'
});
marker_desa = marker_desa.concat(marker);
}
});
overlayLayers['Peta Wilayah Desa'] = wilayah_property(marker_desa,
false);
tampil_peta();
}
});
}

})
// on page loaded
updateValueLuasWilayah();
$('#provinsi_id').select2({
Expand All @@ -79,23 +110,37 @@
placeholder: "Pilih Kecamatan",
allowClear: true
});
$(".sumber_luas_wilayah").change(function(){
$(".sumber_luas_wilayah").change(function() {
updateValueLuasWilayah();
});
});

function path_desa() {
return $.ajax({
type: "get",
url: "{{ route('data.data-desa.getdataajax') }}",
dataType: 'json',
success: function(response) {
return response
}
})
.fail(function() {
return false;
});
}
})

function updateValueLuasWilayah(){
function updateValueLuasWilayah() {
var sumberLuasWilayah = $(".sumber_luas_wilayah").val();
$.ajax({
url: "data-umum/getdataajax",
type: "get",
success: function(response) {
if(sumberLuasWilayah == 1) {
if (sumberLuasWilayah == 1) {
$(".luas_wilayah").val(response.data.luas_wilayah);
$(".luas_wilayah").attr('readonly', false);
} else {
$(".luas_wilayah").val(response.data.luas_wilayah_dari_data_desa);
$(".luas_wilayah").attr('readonly', true);
$(".luas_wilayah").attr('readonly', true);
}
},
error: function(xhr) {
Expand All @@ -104,78 +149,49 @@ function updateValueLuasWilayah(){
});
}
$('.textarea').wysihtml5();

$(function () {
function path_desa () {
return $.ajax({
type: "get",
url: "{{ route('data.data-desa.getdataajax') }}",
dataType: 'json',
success: function (response) {
return response
}
})
.fail(function() {
return false;
});
}

$.when(path_desa()).done(function(res_desa){

if (res_desa) {
var marker_desa = new Array();
var marker;
res_desa.data.forEach(e => {
if (e.path != null) {
marker = set_marker(e, 'Peta Wilayah Desa', 'Wilayah Desa ' + e.nama, {'line' : '#de2d26', 'fill' : '#fff'});
marker_desa = marker_desa.concat(marker);
}
});
overlayLayers['Peta Wilayah Desa'] = wilayah_property(marker_desa, false);
tampil_peta();
}
});
});

var overlayLayers = {};
function tampil_peta () {

function tampil_peta() {
// Inisialisasi tampilan peta
var posisi = [-1.0546279422758742, 116.71875000000001];
var zoom = 10;
var peta_wilayah = L.map('tampil-map', {
center: posisi,
zoom: 13
});

var path_kec = new Array();
if ($('#path').val() != '') {
path_kec = JSON.parse($('#path').val());
showPolygon(path_kec, peta_wilayah)
}
// Geolocation IP Route/GPS
geoLocation(peta_wilayah);

var baseLayers = getBaseLayers(peta_wilayah, '');
L.control.layers(baseLayers, overlayLayers, {
position: 'topleft',
collapsed: true
position: 'topleft',
collapsed: true
}).addTo(peta_wilayah);
// add toolbar
peta_wilayah.pm.addControls(editToolbarPoly());
addpoly(peta_wilayah);
// Menghapus Peta wilayah
hapuslayer(peta_wilayah);
hapuslayer(peta_wilayah);
// Export/Import Peta dari file GPX
eximGpxRegion(peta_wilayah);
eximGpxRegion(peta_wilayah);
// Import Peta dari file SHP
eximShp(peta_wilayah);
peta_wilayah.on('pm:update', function (e) {

peta_wilayah.on('pm:update', function(e) {
setPupup(e.layer);
});

function makePopupContent(feature) {
return
feature.geometry;
}
};
</script>

@endpush
@endpush
6 changes: 0 additions & 6 deletions resources/views/data/data_umum/form_edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,4 @@ class="required">*</span></label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12" >
<div id="tampil-map" style="height:500px"></div>
</div>
</div>

<div class="ln_solid"></div>