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);