Return ID/unige key of custom draggable Markers

4 posts / 0 new
Last post
SLN_DD
Return ID/unige key of custom draggable Markers

Hi,

I display a route with custom markers like in this example: https://developer.mapquest.com/documentation/leaflet-plugins/routing/#st...

I also allow to edit the route over dragging. To receive the the new dragged latLng, I use the "move" and the "dragend" events.

My Problem:

I need to know WHICH marker was dragged.

What I need:

A way to add custom markers, which I can give an id or a key, which updates the route on dragging (like in the example) and which can return their id/key.

 

Has anyone some examples or code for me?

Thanks!!!

 


MQBrianCoakley
I suspect you'll need to use
I suspect you'll need to use the success event to find the new (dragged highlight) or changed (dragged marker) marker. Compare the locations to the previous successful route's locations to find what specific location changed.

SLN_DD
Hmm, this is not what I

Hmm, this is not what I suspected. Is there no way to give each marker its own id?

And if not: how do I get the entire route points (all marker positions)?

 

Thanks!


MQBrianCoakley
If you create a featureGroup
If you create a featureGroup and add it to the map rt = L.featureGroup().addTo(map);and add the route to that featureGroup MQ.routing.routeLayer({directions: dir,fitBounds: true}).addTo(rt);then you can refer to the markers rt.getLayers()[0].markersTo refer to the marker's location you can use something like rt.getLayers()[0].markers[0].location