update: sanity check
This commit is contained in:
@@ -140,11 +140,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.js"></script>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.js"></script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
||||
@@ -159,7 +160,7 @@
|
||||
let regionBoundaryLayer = L.featureGroup().addTo(map);
|
||||
|
||||
function focusToRegionBoundary(selectElement) {
|
||||
regionBoundaryLayer.clearLayers();
|
||||
regionBoundaryLayer.clearLayers(); // Bersihkan garis wilayah sebelumnya
|
||||
|
||||
let selectedOption = selectElement.options[selectElement.selectedIndex];
|
||||
if (!selectedOption || !selectedOption.hasAttribute('data-path')) return;
|
||||
@@ -174,7 +175,7 @@
|
||||
|
||||
function formatCoordinates(coords) {
|
||||
if (coords.length === 2 && typeof coords[0] === 'number') {
|
||||
return [coords[0], coords[1]]; // JANGAN DIBALIK (Leaflet Draw butuh format asli)
|
||||
return [coords[0], coords[1]]; // JANGAN DIBALIK
|
||||
}
|
||||
return coords.map(formatCoordinates);
|
||||
}
|
||||
@@ -182,11 +183,11 @@
|
||||
let latLngs = formatCoordinates(rawData);
|
||||
|
||||
let polygon = L.polygon(latLngs, {
|
||||
color: '#ffc107',
|
||||
fillColor: '#ffc107',
|
||||
fillOpacity: 0.15,
|
||||
weight: 3,
|
||||
dashArray: '8, 6',
|
||||
color: '#3b5998',
|
||||
fillColor: '#3b5998',
|
||||
fillOpacity: 0.1,
|
||||
weight: 2,
|
||||
dashArray: '5, 5',
|
||||
interactive: false
|
||||
});
|
||||
|
||||
@@ -228,8 +229,10 @@
|
||||
|
||||
map.on(L.Draw.Event.CREATED, function (e) {
|
||||
let layer = e.layer;
|
||||
|
||||
drawnItems.clearLayers();
|
||||
drawnItems.addLayer(layer);
|
||||
|
||||
updatePathTextarea(layer);
|
||||
});
|
||||
|
||||
@@ -241,32 +244,14 @@
|
||||
|
||||
map.on(L.Draw.Event.DELETED, function () {
|
||||
document.getElementById('path').value = '';
|
||||
|
||||
let luasInput = document.querySelector('input[name="luas_lahan"]');
|
||||
if (luasInput) luasInput.value = '';
|
||||
});
|
||||
|
||||
function updatePathTextarea(layer) {
|
||||
let latlngs = layer.getLatLngs()[0];
|
||||
|
||||
let pathData = latlngs.map(function(latlng) {
|
||||
return [latlng.lng, latlng.lat];
|
||||
});
|
||||
document.getElementById('path').value = JSON.stringify(pathData);
|
||||
|
||||
let areaSquareMeters = L.GeometryUtil.geodesicArea(latlngs);
|
||||
let areaHectares = areaSquareMeters / 10000;
|
||||
|
||||
let luasInput = document.querySelector('input[name="luas_lahan"]');
|
||||
if (luasInput) {
|
||||
luasInput.value = areaHectares.toFixed(2);
|
||||
luasInput.style.transition = "background-color 0.5s ease";
|
||||
luasInput.style.backgroundColor = "#e8fdf0";
|
||||
|
||||
setTimeout(() => {
|
||||
luasInput.style.backgroundColor = "";
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
|
||||
let statusSelect = document.getElementById('status_kepemilikan');
|
||||
|
||||
@@ -162,11 +162,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.js"></script>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.js"></script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
||||
@@ -203,11 +204,11 @@
|
||||
let latLngs = formatCoordinates(rawData);
|
||||
|
||||
let polygon = L.polygon(latLngs, {
|
||||
color: '#ffc107',
|
||||
fillColor: '#ffc107',
|
||||
fillOpacity: 0.15,
|
||||
weight: 3,
|
||||
dashArray: '8, 6',
|
||||
color: '#3b5998',
|
||||
fillColor: '#3b5998',
|
||||
fillOpacity: 0.1,
|
||||
weight: 2,
|
||||
dashArray: '5, 5',
|
||||
interactive: false
|
||||
});
|
||||
|
||||
@@ -275,32 +276,14 @@
|
||||
|
||||
map.on(L.Draw.Event.DELETED, function () {
|
||||
document.getElementById('path').value = '';
|
||||
|
||||
let luasInput = document.querySelector('input[name="luas_lahan"]');
|
||||
if (luasInput) luasInput.value = '';
|
||||
});
|
||||
|
||||
function updatePathTextarea(layer) {
|
||||
let latlngs = layer.getLatLngs()[0];
|
||||
|
||||
let pathData = latlngs.map(function(latlng) {
|
||||
return [latlng.lng, latlng.lat];
|
||||
});
|
||||
document.getElementById('path').value = JSON.stringify(pathData);
|
||||
|
||||
let areaSquareMeters = L.GeometryUtil.geodesicArea(latlngs);
|
||||
let areaHectares = areaSquareMeters / 10000;
|
||||
|
||||
let luasInput = document.querySelector('input[name="luas_lahan"]');
|
||||
if (luasInput) {
|
||||
luasInput.value = areaHectares.toFixed(2);
|
||||
luasInput.style.transition = "background-color 0.5s ease";
|
||||
luasInput.style.backgroundColor = "#e8fdf0";
|
||||
|
||||
setTimeout(() => {
|
||||
luasInput.style.backgroundColor = "";
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
|
||||
let statusSelect = document.getElementById('status_kepemilikan');
|
||||
|
||||
Reference in New Issue
Block a user