495 lines
27 KiB
HTML
495 lines
27 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>GIS Mandiri - Manajemen Jalan & Parsil Tanah</title>
|
|
|
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.css">
|
|
|
|
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.js"></script>
|
|
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #f0f2f5; }
|
|
#map { height: 75vh; width: 100%; border-radius: 10px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
|
|
.sidebar { background: white; border-radius: 10px; padding: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); height: 75vh; overflow-y: auto; }
|
|
.nav-tabs { border-bottom: 2px solid #dee2e6; margin-bottom: 20px; }
|
|
.nav-tabs .nav-link { border: none; color: #495057; font-weight: 500; padding: 10px 20px; transition: all 0.3s; }
|
|
.nav-tabs .nav-link:hover { color: #0d6efd; }
|
|
.nav-tabs .nav-link.active { color: #0d6efd; border-bottom: 2px solid #0d6efd; background: transparent; }
|
|
.form-group { margin-bottom: 15px; }
|
|
.form-group label { font-weight: 600; margin-bottom: 5px; display: block; color: #495057; }
|
|
.form-group input, .form-group select { width: 100%; padding: 8px 12px; border: 1px solid #ced4da; border-radius: 6px; font-size: 14px; }
|
|
.btn-primary, .btn-danger { padding: 8px 16px; font-size: 14px; border-radius: 6px; margin-right: 8px; margin-top: 5px; }
|
|
.data-list { max-height: 380px; overflow-y: auto; margin-top: 20px; }
|
|
.data-item { background: #f8f9fa; padding: 12px; margin-bottom: 10px; border-radius: 8px; cursor: pointer; transition: all 0.3s; border-left: 4px solid #0d6efd; }
|
|
.data-item:hover { background: #e9ecef; transform: translateX(5px); }
|
|
.data-item strong { display: block; color: #0d6efd; margin-bottom: 5px; }
|
|
.data-item small { color: #6c757d; font-size: 12px; display: block; }
|
|
.draw-controls { margin-top: 10px; padding: 10px; background: white; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
|
.draw-status { background: #e3f2fd; padding: 10px; border-radius: 6px; margin-top: 10px; font-size: 14px; border-left: 4px solid #2196f3; }
|
|
.leaflet-container.drawing-mode { cursor: crosshair !important; }
|
|
|
|
/* Popup Modern UI Style */
|
|
.leaflet-popup-content-wrapper { border-radius: 14px; padding: 0; overflow: hidden; box-shadow: 0 8px 20px rgba(0,0,0,0.15); }
|
|
.leaflet-popup-content { margin: 0 !important; width: 240px; }
|
|
.popup-header { padding: 12px; color: white; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
|
|
.popup-body { padding: 10px 12px; font-size: 13px; color: #444; }
|
|
.popup-row { display: flex; justify-content: space-between; margin-bottom: 4px; }
|
|
.popup-label { color: #888; }
|
|
.popup-value { font-weight: 500; }
|
|
.popup-footer { display: flex; border-top: 1px solid #eee; }
|
|
.popup-btn { flex: 1; padding: 8px; border: none; font-size: 12px; cursor: pointer; transition: 0.2s; }
|
|
.popup-btn-edit { background: #fff3cd; color: #856404; }
|
|
.popup-btn-edit:hover { background: #ffe69c; }
|
|
.popup-btn-delete { background: #f8d7da; color: #842029; }
|
|
.popup-btn-delete:hover { background: #f1aeb5; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container-fluid p-4">
|
|
<h2 class="mb-4">
|
|
<i class="fas fa-map-marked-alt"></i>
|
|
GIS Mandiri - Manajemen Jalan & Parsil Tanah
|
|
</h2>
|
|
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<div id="map"></div>
|
|
<div class="draw-controls">
|
|
<button class="btn btn-primary btn-sm" onclick="startDrawingLine()">
|
|
<i class="fas fa-draw-polygon"></i> Gambar Jalan (Polyline)
|
|
</button>
|
|
<button class="btn btn-warning btn-sm text-dark" onclick="startDrawingPolygon()">
|
|
<i class="fas fa-vector-square"></i> Gambar Parsil Tanah (Polygon)
|
|
</button>
|
|
</div>
|
|
<div id="drawStatus" class="draw-status" style="display:none;"></div>
|
|
</div>
|
|
|
|
<div class="col-md-4">
|
|
<ul class="nav nav-tabs" id="gisTab" role="tablist">
|
|
<li class="nav-item">
|
|
<a class="nav-link active" data-bs-toggle="tab" href="#jalanTab">
|
|
<i class="fas fa-road"></i> Jalan
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" data-bs-toggle="tab" href="#parsilTab">
|
|
<i class="fas fa-landmark"></i> Parsil Tanah
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
|
|
<div class="tab-content">
|
|
<div class="tab-pane fade show active" id="jalanTab">
|
|
<div class="sidebar">
|
|
<h5><i class="fas fa-road"></i> Form Jalan</h5>
|
|
<form id="jalanForm">
|
|
<input type="hidden" id="jalanId">
|
|
<div class="form-group">
|
|
<label><i class="fas fa-sign"></i> Nama Jalan</label>
|
|
<input type="text" id="namaJalan" class="form-control" placeholder="Contoh: Jalan Ahmad Yani" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label><i class="fas fa-tag"></i> Status Jalan</label>
|
|
<select id="statusJalan" class="form-control">
|
|
<option value="nasional">🔴 Jalan Nasional (Merah)</option>
|
|
<option value="provinsi">🟠 Jalan Provinsi (Orange)</option>
|
|
<option value="kabupaten">🔵 Jalan Kabupaten (Biru)</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label><i class="fas fa-ruler"></i> Panjang Jalan (meter)</label>
|
|
<input type="text" id="panjangJalan" class="form-control" readonly placeholder="Akan dihitung otomatis">
|
|
</div>
|
|
<button type="submit" class="btn btn-primary"><i class="fas fa-save"></i> Simpan</button>
|
|
<button type="button" class="btn btn-danger" onclick="cancelDrawing(); resetJalanForm();"><i class="fas fa-times"></i> Batal</button>
|
|
</form>
|
|
<hr>
|
|
<h6><i class="fas fa-list"></i> Daftar Jalan</h6>
|
|
<div class="input-group input-group-sm mb-3">
|
|
<span class="input-group-text bg-primary text-white"><i class="fas fa-search"></i></span>
|
|
<input type="text" id="searchJalan" class="form-control" placeholder="Cari Jalan...">
|
|
</div>
|
|
<div id="jalanList" class="data-list"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tab-pane fade" id="parsilTab">
|
|
<div class="sidebar">
|
|
<h5><i class="fas fa-vector-square"></i> Form Parsil Tanah</h5>
|
|
<form id="parsilForm">
|
|
<input type="hidden" id="parsilId">
|
|
<div class="form-group">
|
|
<label><i class="fas fa-home"></i> Nama Kavling</label>
|
|
<input type="text" id="namaParcil" class="form-control" placeholder="Contoh: Kavling Citra Garden" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label><i class="fas fa-certificate"></i> Status Kepemilikan</label>
|
|
<select id="statusKepemilikan" class="form-control">
|
|
<option value="SHM">🟢 SHM (Hak Milik)</option>
|
|
<option value="HGB">🔵 HGB (Hak Guna Bangunan)</option>
|
|
<option value="HGU">🟠 HGU (Hak Guna Usaha)</option>
|
|
<option value="HP">🟣 HP (Hak Pakai)</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label><i class="fas fa-chart-area"></i> Luas Tanah (m²)</label>
|
|
<input type="text" id="luasTanah" class="form-control" readonly placeholder="Akan dihitung otomatis">
|
|
</div>
|
|
<button type="submit" class="btn btn-primary"><i class="fas fa-save"></i> Simpan</button>
|
|
<button type="button" class="btn btn-danger" onclick="cancelDrawing(); resetParcilForm();"><i class="fas fa-times"></i> Batal</button>
|
|
</form>
|
|
<hr>
|
|
<h6><i class="fas fa-list"></i> Daftar Parsil Tanah</h6>
|
|
<div class="input-group input-group-sm mb-3">
|
|
<span class="input-group-text bg-primary text-white"><i class="fas fa-search"></i></span>
|
|
<input type="text" id="searchParcil" class="form-control" placeholder="Cari Parsil...">
|
|
</div>
|
|
<div id="parsilList" class="data-list"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Endpoint API disesuaikan ke file api.php bawaan Anda
|
|
const API_URL = 'api.php';
|
|
|
|
// Inisialisasi Peta (Default Lokasi Pontianak)
|
|
const map = L.map('map').setView([-0.026330, 109.342519], 13);
|
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
attribution: '© OpenStreetMap contributors'
|
|
}).addTo(map);
|
|
|
|
// Feature Group untuk menampung gambar dari database
|
|
const jalanLayer = L.featureGroup().addTo(map);
|
|
const parsilLayer = L.featureGroup().addTo(map);
|
|
|
|
// Handler untuk Leaflet Draw
|
|
let currentDrawHandler = null;
|
|
let temporaryCoordinates = null;
|
|
let isEditingMode = false;
|
|
|
|
// Warna styling spasial bawaan sistem asli
|
|
const statusColors = { nasional: '#dc3545', provinsi: '#fd7e14', kabupaten: '#0d6efd' };
|
|
|
|
// Menyesuaikan dengan value option select di database Anda: SHM, HGB, HGU, HP
|
|
const parsilColors = { SHM: '#28a745', HGB: '#007bff', HGU: '#ffc107', HP: '#6f42c1' };
|
|
|
|
// ==================== LOAD DATA FUNCTION ====================
|
|
function loadJalan() {
|
|
fetch(`${API_URL}?type=jalan&action=getAll`)
|
|
.then(res => res.json())
|
|
.then(res => {
|
|
if(!res.success) return;
|
|
jalanLayer.clearLayers();
|
|
const listContainer = document.getElementById('jalanList');
|
|
listContainer.innerHTML = '';
|
|
|
|
const query = document.getElementById('searchJalan').value.toLowerCase();
|
|
|
|
res.data.forEach(item => {
|
|
if(query && !item.nama.toLowerCase().includes(query) && !item.status.toLowerCase().includes(query)) return;
|
|
|
|
const coords = item.coordinates;
|
|
const polyline = L.polyline(coords, {
|
|
color: statusColors[item.status] || '#6c757d',
|
|
weight: 5,
|
|
opacity: 0.8
|
|
}).addTo(jalanLayer);
|
|
|
|
const coordsString = JSON.stringify(coords);
|
|
|
|
const popupContent = `
|
|
<div class="popup-header" style="background:${statusColors[item.status] || '#6c757d'}">
|
|
<i class="fas fa-road"></i> ${item.nama}
|
|
</div>
|
|
<div class="popup-body">
|
|
<div class="popup-row"><span class="popup-label">Status:</span><span class="popup-value">${item.status.toUpperCase()}</span></div>
|
|
<div class="popup-row"><span class="popup-label">Panjang:</span><span class="popup-value">${parseFloat(item.panjang).toFixed(1)} m</span></div>
|
|
</div>
|
|
<div class="popup-footer">
|
|
<button class="popup-btn popup-btn-edit" onclick="editJalan(${item.id}, '${escapeHtml(item.nama)}', '${item.status}', ${item.panjang}, '${escapeHtml(coordsString)}')"><i class="fas fa-edit"></i> Edit</button>
|
|
<button class="popup-btn popup-btn-delete" onclick="deleteData('jalan', ${item.id})"><i class="fas fa-trash"></i> Hapus</button>
|
|
</div>`;
|
|
polyline.bindPopup(popupContent);
|
|
|
|
const div = document.createElement('div');
|
|
div.className = 'data-item';
|
|
div.style.borderLeftColor = statusColors[item.status] || '#6c757d';
|
|
div.innerHTML = `<strong>${item.nama}</strong><small>Status: ${item.status.toUpperCase()} | ${parseFloat(item.panjang).toFixed(1)} m</small>`;
|
|
div.onclick = () => { map.fitBounds(polyline.getBounds()); polyline.openPopup(); };
|
|
listContainer.appendChild(div);
|
|
});
|
|
}).catch(err => console.error("Gagal memuat data jalan:", err));
|
|
}
|
|
|
|
function loadParsil() {
|
|
fetch(`${API_URL}?type=parsil&action=getAll`)
|
|
.then(res => res.json())
|
|
.then(res => {
|
|
// Pengecekan debug untuk melihat data di Console Log F12 Browser
|
|
console.log("Data Parsil dari Database:", res);
|
|
|
|
if(!res.success) {
|
|
console.error("Gagal mengambil data parsil:", res.message);
|
|
return;
|
|
}
|
|
|
|
parsilLayer.clearLayers();
|
|
const listContainer = document.getElementById('parsilList');
|
|
listContainer.innerHTML = '';
|
|
|
|
const query = document.getElementById('searchParcil').value.toLowerCase();
|
|
|
|
res.data.forEach(item => {
|
|
// SINKRONISASI UTAMA: api.php Anda mengembalikan field bernama 'nama' dan 'status'
|
|
const namaTanah = item.nama || 'Tanpa Nama';
|
|
const statusTanah = item.status || 'SHM';
|
|
|
|
if(query && !namaTanah.toLowerCase().includes(query) && !statusTanah.toLowerCase().includes(query)) return;
|
|
|
|
let coords = item.coordinates;
|
|
if (!coords || coords.length === 0) return;
|
|
|
|
// PROTEKSI STRUKTUR KOORDINAT POLYGON LEAFLET:
|
|
// Jika koordinat dari database berbentuk array datar [[lat,lng], [lat,lng]],
|
|
// Leaflet Polygon akan error. Kode ini otomatis membungkusnya menjadi [[[lat,lng], [lat,lng]]]
|
|
if (Array.isArray(coords) && coords.length > 0 && !Array.isArray(coords[0][0])) {
|
|
coords = [coords];
|
|
}
|
|
|
|
try {
|
|
// Menggambar Poligon Wilayah Tanah di Leaflet
|
|
const polygon = L.polygon(coords, {
|
|
color: parsilColors[statusTanah] || '#6c757d',
|
|
fillColor: parsilColors[statusTanah] || '#6c757d',
|
|
fillOpacity: 0.4,
|
|
weight: 2
|
|
}).addTo(parsilLayer);
|
|
|
|
const coordsString = JSON.stringify(item.coordinates);
|
|
|
|
// Bind Popup Spasial Parsil
|
|
const popupContent = `
|
|
<div class="popup-header" style="background:${parsilColors[statusTanah] || '#6c757d'}">
|
|
<i class="fas fa-landmark"></i> ${namaTanah}
|
|
</div>
|
|
<div class="popup-body">
|
|
<div class="popup-row"><span class="popup-label">Kepemilikan:</span><span class="popup-value">${statusTanah}</span></div>
|
|
<div class="popup-row"><span class="popup-label">Luas:</span><span class="popup-value">${parseFloat(item.luas).toFixed(1)} m²</span></div>
|
|
</div>
|
|
<div class="popup-footer">
|
|
<button class="popup-btn popup-btn-edit" onclick="editParsil(${item.id}, '${escapeHtml(namaTanah)}', '${statusTanah}', ${item.luas}, '${escapeHtml(coordsString)}')"><i class="fas fa-edit"></i> Edit</button>
|
|
<button class="popup-btn popup-btn-delete" onclick="deleteData('parsil', ${item.id})"><i class="fas fa-trash"></i> Hapus</button>
|
|
</div>`;
|
|
polygon.bindPopup(popupContent);
|
|
|
|
// Render ke List Sidebar Kiri
|
|
const div = document.createElement('div');
|
|
div.className = 'data-item';
|
|
div.style.borderLeftColor = parsilColors[statusTanah] || '#6c757d';
|
|
div.innerHTML = `<strong>${namaTanah}</strong><small>Hak: ${statusTanah} | Luas: ${parseFloat(item.luas).toFixed(1)} m²</small>`;
|
|
div.onclick = () => { map.fitBounds(polygon.getBounds()); polygon.openPopup(); };
|
|
listContainer.appendChild(div);
|
|
} catch (leafletError) {
|
|
console.error("Format data koordinat parsil rusak atau tidak valid untuk Leaflet:", coords, leafletError);
|
|
}
|
|
});
|
|
}).catch(err => console.error("Gagal memproses fetch parsil:", err));
|
|
}
|
|
|
|
// ==================== DRAWING MANAGEMENT ====================
|
|
function setDrawStatus(show, message = "") {
|
|
const el = document.getElementById('drawStatus');
|
|
const mapEl = document.getElementById('map');
|
|
if (show) {
|
|
el.style.display = 'block';
|
|
el.innerHTML = message;
|
|
mapEl.classList.add('drawing-mode');
|
|
} else {
|
|
el.style.display = 'none';
|
|
mapEl.classList.remove('drawing-mode');
|
|
}
|
|
}
|
|
|
|
function cancelDrawing() {
|
|
if(currentDrawHandler) {
|
|
currentDrawHandler.disable();
|
|
currentDrawHandler = null;
|
|
}
|
|
setDrawStatus(false);
|
|
isEditingMode = false;
|
|
}
|
|
|
|
function startDrawingLine() {
|
|
cancelDrawing();
|
|
document.querySelector('a[href="#jalanTab"]').click();
|
|
resetJalanForm();
|
|
|
|
currentDrawHandler = new L.Draw.Polyline(map, { shapeOptions: { color: '#0d6efd', weight: 4 } });
|
|
currentDrawHandler.enable();
|
|
setDrawStatus(true, '<i class="fas fa-info-circle"></i> Mode Menggambar Jalan: Klik pada peta untuk rute jalan, klik titik terakhir untuk selesai.');
|
|
}
|
|
|
|
function startDrawingPolygon() {
|
|
cancelDrawing();
|
|
document.querySelector('a[href="#parsilTab"]').click();
|
|
resetParcilForm();
|
|
|
|
currentDrawHandler = new L.Draw.Polygon(map, { shapeOptions: { color: '#28a745', fillOpacity: 0.2 } });
|
|
currentDrawHandler.enable();
|
|
setDrawStatus(true, '<i class="fas fa-info-circle"></i> Mode Menggambar Parsil: Klik peta untuk membentuk wilayah parsil tanah.');
|
|
}
|
|
|
|
map.on(L.Draw.Event.CREATED, function (e) {
|
|
const layer = e.layer;
|
|
cancelDrawing();
|
|
|
|
if (e.layerType === 'polyline') {
|
|
const latlngs = layer.getLatLngs();
|
|
temporaryCoordinates = latlngs.map(ll => [ll.lat, ll.lng]);
|
|
|
|
let distance = 0;
|
|
for (let i = 0; i < latlngs.length - 1; i++) {
|
|
distance += latlngs[i].distanceTo(latlngs[i+1]);
|
|
}
|
|
document.getElementById('panjangJalan').value = distance.toFixed(2);
|
|
}
|
|
else if (e.layerType === 'polygon') {
|
|
const latlngs = layer.getLatLngs()[0];
|
|
temporaryCoordinates = latlngs.map(ll => [ll.lat, ll.lng]);
|
|
|
|
const area = L.GeometryUtil.geodesicArea(latlngs);
|
|
document.getElementById('luasTanah').value = area.toFixed(2);
|
|
}
|
|
});
|
|
|
|
// ==================== CRUD FORM MANAGEMENT ====================
|
|
document.getElementById('jalanForm').onsubmit = function(e) {
|
|
e.preventDefault();
|
|
const id = document.getElementById('jalanId').value;
|
|
|
|
if(!id && !temporaryCoordinates) {
|
|
alert("Silakan gambarkan jalan pada peta terlebih dahulu!");
|
|
return;
|
|
}
|
|
|
|
const payload = {
|
|
nama: document.getElementById('namaJalan').value,
|
|
status: document.getElementById('statusJalan').value,
|
|
panjang: parseFloat(document.getElementById('panjangJalan').value),
|
|
coordinates: temporaryCoordinates
|
|
};
|
|
|
|
const url = id ? `${API_URL}?type=jalan&action=update&id=${id}` : `${API_URL}?type=jalan&action=create`;
|
|
const method = id ? 'PUT' : 'POST';
|
|
|
|
fetch(url, { method: method, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) })
|
|
.then(res => res.json())
|
|
.then(res => {
|
|
alert(res.message);
|
|
if(res.success) { resetJalanForm(); loadJalan(); }
|
|
});
|
|
};
|
|
|
|
document.getElementById('parsilForm').onsubmit = function(e) {
|
|
e.preventDefault();
|
|
const id = document.getElementById('parsilId').value;
|
|
|
|
if(!id && !temporaryCoordinates) {
|
|
alert("Silakan gambarkan batas wilayah parsil pada peta terlebih dahulu!");
|
|
return;
|
|
}
|
|
|
|
// SINKRONISASI PAYLOAD POST: Menggunakan properti 'nama' dan 'status' sesuai query api.php Anda
|
|
const payload = {
|
|
nama: document.getElementById('namaParcil').value,
|
|
status: document.getElementById('statusKepemilikan').value,
|
|
luas: parseFloat(document.getElementById('luasTanah').value),
|
|
coordinates: temporaryCoordinates
|
|
};
|
|
|
|
const url = id ? `${API_URL}?type=parsil&action=update&id=${id}` : `${API_URL}?type=parsil&action=create`;
|
|
const method = id ? 'PUT' : 'POST';
|
|
|
|
fetch(url, { method: method, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) })
|
|
.then(res => res.json())
|
|
.then(res => {
|
|
alert(res.message);
|
|
if(res.success) { resetParcilForm(); loadParcil(); }
|
|
});
|
|
};
|
|
|
|
function editJalan(id, nama, status, panjang, coordsStr) {
|
|
cancelDrawing();
|
|
isEditingMode = true;
|
|
document.querySelector('a[href="#jalanTab"]').click();
|
|
document.getElementById('jalanId').value = id;
|
|
document.getElementById('namaJalan').value = nama;
|
|
document.getElementById('statusJalan').value = status;
|
|
document.getElementById('panjangJalan').value = panjang;
|
|
temporaryCoordinates = JSON.parse(coordsStr);
|
|
}
|
|
|
|
function editParsil(id, nama, status, luas, coordsStr) {
|
|
cancelDrawing();
|
|
isEditingMode = true;
|
|
document.querySelector('a[href="#parsilTab"]').click();
|
|
document.getElementById('parsilId').value = id;
|
|
document.getElementById('namaParcil').value = nama;
|
|
document.getElementById('statusKepemilikan').value = status;
|
|
document.getElementById('luasTanah').value = luas;
|
|
|
|
let coords = JSON.parse(coordsStr);
|
|
if (Array.isArray(coords) && coords.length > 0 && Array.isArray(coords[0][0])) {
|
|
coords = coords[0];
|
|
}
|
|
temporaryCoordinates = coords;
|
|
}
|
|
|
|
function deleteData(type, id) {
|
|
if(confirm(`Apakah Anda yakin ingin menghapus data ${type} ini?`)) {
|
|
fetch(`${API_URL}?type=${type}&action=delete&id=${id}`, { method: 'DELETE' })
|
|
.then(res => res.json())
|
|
.then(res => {
|
|
alert(res.message);
|
|
if(type === 'jalan') loadJalan(); else loadParsil();
|
|
});
|
|
}
|
|
}
|
|
|
|
function resetJalanForm() {
|
|
document.getElementById('jalanForm').reset();
|
|
document.getElementById('jalanId').value = '';
|
|
temporaryCoordinates = null;
|
|
}
|
|
function resetParcilForm() {
|
|
document.getElementById('parsilForm').reset();
|
|
document.getElementById('parsilId').value = '';
|
|
temporaryCoordinates = null;
|
|
}
|
|
function escapeHtml(text) {
|
|
if (!text) return '';
|
|
return text.toString().replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
}
|
|
|
|
document.getElementById('searchJalan').addEventListener('input', loadJalan);
|
|
document.getElementById('searchParcil').addEventListener('input', loadParsil);
|
|
|
|
// ==================== INITIAL LOAD ====================
|
|
loadJalan();
|
|
loadParsil();
|
|
</script>
|
|
</body>
|
|
</html> |