fix all bug
This commit is contained in:
@@ -299,6 +299,42 @@ body::before {
|
||||
}
|
||||
.leaflet-control-zoom a:hover { background: var(--primary-deep) !important; color: white !important; }
|
||||
|
||||
/* Custom Leaflet Layer Control style to match theme */
|
||||
.leaflet-control-layers {
|
||||
background: var(--bg-glass) !important;
|
||||
backdrop-filter: blur(24px) !important;
|
||||
-webkit-backdrop-filter: blur(24px) !important;
|
||||
border: 1px solid var(--border-glass) !important;
|
||||
border-radius: 14px !important;
|
||||
box-shadow: var(--shadow) !important;
|
||||
color: var(--text-main) !important;
|
||||
font-family: var(--font) !important;
|
||||
padding: 10px 14px !important;
|
||||
transition: var(--transition);
|
||||
}
|
||||
.leaflet-control-layers-expanded {
|
||||
min-width: 140px;
|
||||
}
|
||||
.leaflet-control-layers label {
|
||||
margin-bottom: 6px !important;
|
||||
font-size: 0.85rem !important;
|
||||
cursor: pointer !important;
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
gap: 8px !important;
|
||||
color: var(--text-main) !important;
|
||||
font-weight: 500;
|
||||
}
|
||||
.leaflet-control-layers label:last-child {
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
.leaflet-control-layers input[type="checkbox"] {
|
||||
cursor: pointer !important;
|
||||
width: 15px !important;
|
||||
height: 15px !important;
|
||||
accent-color: var(--primary-deep) !important;
|
||||
}
|
||||
|
||||
.leaflet-popup-content-wrapper {
|
||||
background: var(--bg-glass) !important;
|
||||
backdrop-filter: blur(16px) !important;
|
||||
|
||||
+28
-1
@@ -65,6 +65,33 @@
|
||||
<p>Kumulatif P01 & P02 + Choropleth Map (Point-in-Polygon).</p>
|
||||
</div>
|
||||
|
||||
<!-- Layer Peta (Centang) -->
|
||||
<div class="menu-group">
|
||||
<div class="menu-title">Layer Peta</div>
|
||||
<div class="form-panel" style="gap: 10px;">
|
||||
<label class="checkbox-group">
|
||||
<input type="checkbox" id="layer-spbu" checked>
|
||||
<span>Stasiun SPBU</span>
|
||||
</label>
|
||||
<label class="checkbox-group">
|
||||
<input type="checkbox" id="layer-jalan" checked>
|
||||
<span>Jalur Jalan</span>
|
||||
</label>
|
||||
<label class="checkbox-group">
|
||||
<input type="checkbox" id="layer-rumah" checked>
|
||||
<span>Rumah Ibadah</span>
|
||||
</label>
|
||||
<label class="checkbox-group">
|
||||
<input type="checkbox" id="layer-warga" checked>
|
||||
<span>Warga Miskin</span>
|
||||
</label>
|
||||
<label class="checkbox-group">
|
||||
<input type="checkbox" id="layer-choro" checked>
|
||||
<span>Choropleth Kepadatan</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Draw Tools -->
|
||||
<div class="menu-group">
|
||||
<div class="menu-title">Draw Tools</div>
|
||||
@@ -132,7 +159,7 @@
|
||||
icon.className = t === 'dark' ? 'fas fa-sun' : 'fas fa-moon';
|
||||
}
|
||||
</script>
|
||||
<script type="module" src="js/app.js"></script>
|
||||
<script type="module" src="js/app.js?v=20260613-9"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+49
-14
@@ -30,14 +30,6 @@ window.showToast = (msg, type='success') => {
|
||||
setTimeout(() => { t.style.opacity=0; setTimeout(()=>t.remove(),300); }, 3000);
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
appMap = initMap('map');
|
||||
document.getElementById('btn-draw-rumah')?.addEventListener('click', () => { window.currentDrawType='rumah_ibadah'; new L.Draw.Marker(appMap).enable(); });
|
||||
document.getElementById('btn-draw-warga')?.addEventListener('click', () => { window.currentDrawType='warga_miskin'; new L.Draw.Marker(appMap).enable(); });
|
||||
drawControl = setupDrawControls(appMap, handleGeometryCreated);
|
||||
await loadAllData();
|
||||
});
|
||||
|
||||
const loadAllData = async () => {
|
||||
try {
|
||||
const [spbu, jalan, choro, rumah, warga] = await Promise.all([
|
||||
@@ -45,13 +37,13 @@ const loadAllData = async () => {
|
||||
rumahIbadahService.getAll(), wargaMiskinService.getAll()
|
||||
]);
|
||||
|
||||
L.geoJSON(spbu, { pointToLayer: (f, ll) => L.marker(ll, { icon: iconSPBU(f.properties.buka_24_jam) }), onEachFeature: (f, l) => bindPopup(l, 'spbu', f.properties) }).addTo(appMap);
|
||||
L.geoJSON(jalan, { style: { color: '#F59E0B', weight: 4 }, onEachFeature: (f, l) => bindPopup(l, 'jalan', f.properties) }).addTo(appMap);
|
||||
L.geoJSON(rumah, { pointToLayer: (f, ll) => L.marker(ll, { icon: iconRumah }), onEachFeature: (f, l) => bindPopup(l, 'rumah_ibadah', f.properties) }).addTo(appMap);
|
||||
L.geoJSON(warga, { pointToLayer: (f, ll) => L.marker(ll, { icon: iconWarga }), onEachFeature: (f, l) => bindPopup(l, 'warga_miskin', f.properties) }).addTo(appMap);
|
||||
const spbuLayer = L.geoJSON(spbu, { pointToLayer: (f, ll) => L.marker(ll, { icon: iconSPBU(f.properties.buka_24_jam) }), onEachFeature: (f, l) => bindPopup(l, 'spbu', f.properties) }).addTo(appMap);
|
||||
const jalanLayer = L.geoJSON(jalan, { style: { color: '#F59E0B', weight: 4 }, onEachFeature: (f, l) => bindPopup(l, 'jalan', f.properties) }).addTo(appMap);
|
||||
const rumahLayer = L.geoJSON(rumah, { pointToLayer: (f, ll) => L.marker(ll, { icon: iconRumah }), onEachFeature: (f, l) => bindPopup(l, 'rumah_ibadah', f.properties) }).addTo(appMap);
|
||||
const wargaLayer = L.geoJSON(warga, { pointToLayer: (f, ll) => L.marker(ll, { icon: iconWarga }), onEachFeature: (f, l) => bindPopup(l, 'warga_miskin', f.properties) }).addTo(appMap);
|
||||
|
||||
let merahCount = 0;
|
||||
L.geoJSON(choro, {
|
||||
const choroLayer = L.geoJSON(choro, {
|
||||
style: (f) => {
|
||||
const count = f.properties.jumlah_warga_miskin;
|
||||
let c = '#10B981'; // Hijau (0)
|
||||
@@ -62,6 +54,28 @@ const loadAllData = async () => {
|
||||
onEachFeature: (f, l) => bindPopup(l, 'kavling', f.properties)
|
||||
}).addTo(appMap);
|
||||
|
||||
// Bind checkbox events
|
||||
document.getElementById('layer-spbu').addEventListener('change', (e) => {
|
||||
if (e.target.checked) appMap.addLayer(spbuLayer);
|
||||
else appMap.removeLayer(spbuLayer);
|
||||
});
|
||||
document.getElementById('layer-jalan').addEventListener('change', (e) => {
|
||||
if (e.target.checked) appMap.addLayer(jalanLayer);
|
||||
else appMap.removeLayer(jalanLayer);
|
||||
});
|
||||
document.getElementById('layer-rumah').addEventListener('change', (e) => {
|
||||
if (e.target.checked) appMap.addLayer(rumahLayer);
|
||||
else appMap.removeLayer(rumahLayer);
|
||||
});
|
||||
document.getElementById('layer-warga').addEventListener('change', (e) => {
|
||||
if (e.target.checked) appMap.addLayer(wargaLayer);
|
||||
else appMap.removeLayer(wargaLayer);
|
||||
});
|
||||
document.getElementById('layer-choro').addEventListener('change', (e) => {
|
||||
if (e.target.checked) appMap.addLayer(choroLayer);
|
||||
else appMap.removeLayer(choroLayer);
|
||||
});
|
||||
|
||||
document.getElementById('stat-total-warga').innerText = warga.features.length;
|
||||
document.getElementById('stat-kavling-merah').innerText = merahCount;
|
||||
|
||||
@@ -101,10 +115,31 @@ const handleGeometryCreated = (type, geometry, layer) => {
|
||||
try {
|
||||
if(type==='spbu') await spbuService.create(payload);
|
||||
if(type==='jalan') await jalanService.create(payload);
|
||||
if(type==='kavling') await kavlingService.create(payload);
|
||||
if(type==='kavling') {
|
||||
const kavlingPayload = {
|
||||
nama_pemilik: payload.nama,
|
||||
luas: payload.luas || 0,
|
||||
geometry: payload.geometry
|
||||
};
|
||||
await kavlingService.create(kavlingPayload);
|
||||
}
|
||||
if(type==='rumah_ibadah') await rumahIbadahService.create(payload);
|
||||
if(type==='warga_miskin') await wargaMiskinService.create(payload);
|
||||
window.showToast('Tersimpan'); setTimeout(()=>location.reload(), 800);
|
||||
} catch(e) { window.showToast('Gagal simpan', 'error'); }
|
||||
}, () => appMap.removeLayer(tempLayer));
|
||||
};
|
||||
|
||||
const init = async () => {
|
||||
appMap = initMap('map');
|
||||
document.getElementById('btn-draw-rumah')?.addEventListener('click', () => { window.currentDrawType='rumah_ibadah'; new L.Draw.Marker(appMap).enable(); });
|
||||
document.getElementById('btn-draw-warga')?.addEventListener('click', () => { window.currentDrawType='warga_miskin'; new L.Draw.Marker(appMap).enable(); });
|
||||
drawControl = setupDrawControls(appMap, handleGeometryCreated);
|
||||
await loadAllData();
|
||||
};
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user