Fix up marker drag end event for detecting when the marker moves

This commit is contained in:
Eli Ribble 2026-01-30 21:38:29 +00:00
parent 27927c506e
commit 96e3441556
No known key found for this signature in database
2 changed files with 3 additions and 2 deletions

View file

@ -116,13 +116,13 @@ class MapLocator extends HTMLElement {
color: "#FF0000",
draggable: true
}).setLngLat(coords).addTo(this._map);
marker.on('dragend', function(e) {
marker.on('dragend', (e) => {
const markerDraggedEvent = new CustomEvent("markerdragend", {
detail: {
marker: marker
}
});
mapContainer.dispatchEvent(markerDraggedEvent);
this.dispatchEvent(markerDraggedEvent);
});
this._markers = [marker];
}

View file

@ -120,6 +120,7 @@ document.addEventListener('DOMContentLoaded', function() {
mapZoom.value = e.target.getZoom();
});
mapLocator.addEventListener("markerdragend", (e) => {
const marker = event.detail.marker;
const lngLat = marker.getLngLat();
//displaySelectedCoordinates(lngLat);
geocodeReverse(MAPBOX_ACCESS_TOKEN, lngLat);