var result = []; $(document).ready(function () { PopulateLokasi(); }); function PopulateLokasi() { $.ajax({ url: "https://banksampah.jakarta.go.id/api/web/index", method: 'GET', success: function (result) { arrTipeLokasi = []; arrTipeLokasi = result; drawTipeLokasi(result); } }); } function drawTipeLokasi(result) { const map = L.map('map', { scrollWheelZoom: false }) //.setView([-6.149451590260942, 106.84327788839438], 10.5) .setView([-6.18451590260942, 106.84327788839438], 11.5) L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '  ' }).addTo(map); [ "jakut", "jaksel", "jakpus", "jaktim", "jakbar", "kep1000", ].map((city) => { $.getJSON(`/StaticFiles/geojson/id-jk-${city}.geojson`, (data) => { L.geoJSON(data, { color: '#4f9bd9', fillColor: '#fff', fillOpacity: 0.1, radius: 500 }).addTo(map); }) }) let markers = [], options for (var i in result) { var regexLat = new RegExp('^(\\+|-)?(?:90(?:(?:\\.0{1,20})?)|(?:[0-9]|[1-8][0-9])(?:(?:\\.[0-9]{1,20})?))$'); var regexLong = new RegExp('^(\\+|-)?(?:180(?:(?:\\.0{1,20})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\\.[0-9]{1,20})?))$'); if (!regexLat.exec(result[i].latitude)) { console.log(result[i].id+" - "+result[i].latitude); } else if (!regexLong.exec(result[i].longitude)) { console.log(result[i].id + " - " +result[i].longitude); } else { options = { icon: L.divIcon({ iconSize: 'auto', html: `
`, }) } markers[100] = L.marker([result[i].latitude, result[i].longitude], options).addTo(map); } } var legend = L.control({ position: "bottomleft" }); legend.onAdd = function (map) { var div = L.DomUtil.create("div", "legend"); div.innerHTML += "

Keterangan

"; div.innerHTML += 'Bank Sampah Unit
'; div.innerHTML += 'Bank Sampah Induk
'; return div; }; legend.addTo(map); }