fix: truly hide map pin

This commit is contained in:
relikd
2024-07-03 00:21:03 +02:00
parent ea5d41a8ad
commit 10316bd247

View File

@@ -23,7 +23,7 @@ function MapLocationInit(mapId, options = {}) {
return valField.value.split(',');
}
}
const marker = L.marker(loadPos(), { draggable: true }).addTo(map);
const marker = L.marker(loadPos(), { draggable: true });
marker.on('move', function (e) {
const pos = map.wrapLatLng(e.latlng);
const flag = isZero(pos);
@@ -43,12 +43,12 @@ function MapLocationInit(mapId, options = {}) {
function setMapState(initial) {
theMap.style.cursor = initial ? 'crosshair' : null;
marker.setOpacity(initial ? 0 : 1);
initial ? marker.remove() : marker.addTo(map);
}
if (isZero(marker.getLatLng())) {
setMapState(true);
} else {
setMapState(isZero(marker.getLatLng()));
if (valField.value) {
map.setView(valField.value.split(','), options.markerZoom || 18);
}
// re-center map