{
let container = htl.html`<div style="height:${450}px; width:${width}px">`;
yield container;
const map = L.map(container);
map.locate({ setView: true });
map.preferCanvas = true;
L.tileLayer(
"https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}@2x.png",
{
attribution:
'© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}
).addTo(map);
var geolayer = L.geoJson(indo_convex_hull).addTo(map);
map.fitBounds(geolayer.getBounds());
var marker = new L.marker([], {
draggable: true,
autoPan: true
});
marker.on("dragend", async function (e) {
let lat = e.target._latlng.lat,
lng = e.target._latlng.lng;
geocode([lng, lat]).then((address) => {
info.update(geofence([lng, lat], indo_convex_hull), address);
});
});
function onLocationFound(e) {
var radius = e.accuracy;
marker.setLatLng(e.latlng);
marker.addTo(map);
}
map.on("locationfound", onLocationFound);
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create("div", "info");
this.update();
return this._div;
};
info.update = function (bool, address) {
if (!bool) {
address = "You're not in Indonesia";
}
this._div.innerHTML = "<b>" + bool + "</b><br />" + address + "<br />";
};
info.addTo(map);
}