Fix up marker drag end event for detecting when the marker moves
This commit is contained in:
parent
27927c506e
commit
96e3441556
2 changed files with 3 additions and 2 deletions
|
|
@ -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];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue