From 96e3441556ec6b880af37cdf694725417ae53e61 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Fri, 30 Jan 2026 21:38:29 +0000 Subject: [PATCH] Fix up marker drag end event for detecting when the marker moves --- html/static/js/map-locator.js | 4 ++-- rmo/template/nuisance.html | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/html/static/js/map-locator.js b/html/static/js/map-locator.js index 48322624..c612077e 100644 --- a/html/static/js/map-locator.js +++ b/html/static/js/map-locator.js @@ -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]; } diff --git a/rmo/template/nuisance.html b/rmo/template/nuisance.html index 43412b18..df798e64 100644 --- a/rmo/template/nuisance.html +++ b/rmo/template/nuisance.html @@ -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);