How do I catch when a route has been dragged?

4 posts / 0 new
Last post
lchinitz
How do I catch when a route has been dragged?

Question highlight:  I'd like to know how to catch it when a user drags the route on the map.  I am sure there is some event that is being thrown, but I can't find it.

Question details:

I have a website that makes closed-route routes for cycling and running, www.routeloops.com.  I have had a version using the Mapquest API for OSM for a while, but there were changes made using Leaflet, etc., and I've had to take it down in order to redo the code.  I am now pretty close to getting it back, but I'm still stuck on one point.  To see it, though, you can look at www.routeloops.com/LeafletMQ.

Routes are being correctly generated, but when the user drags the route on the map, I can't see how to know that that has happened.  When I draw the route on the map, I am using:

directionsLayer = L.mapquest.directionsLayer({

   directionsResponse: response

}).addTo(myMap);

 

If I examine directionsLayer.route.route.shape.shapePoints, I can see the number of points on the route.  If I drag the route and watch this number of shape points in the debugger, I can see it changing.  So I am sure that the information I need is being updated.  But I can't figure out how to CATCH that this change has happened.  I'd like to be able to run some code whenever the route is dragged.

 

Can someone tell me what I need to do?

 

Thanks.


MQBrianCoakley
You can use the 'success'
You can use the 'success' event as shown in the route narrative sample.   update: It looks like you're actually using the new MapQuest.js sdk. This functionality it not built in yet. Keep checking back though...

lchinitz
OK, thanks.  By the way, the

OK, thanks.  By the way, the "success" event, which I used previously when I was messing with the Leaflet SDK, is a little too broad.  It fires on everything -- new routes, dragged routes, etc.  As long as you are still building in functionality, I'd like to put in a request for something like "dragend" for dragging a route.  It would be great to know when a user had finished dragging a route to a new location.  I don't need to know every single drag point, just when a drag has happened.  


MQBrianCoakley
Thanks for the suggestion. I
Thanks for the suggestion. I forwareded this on to the team to assess.