perliedman / leaflet-routing-machine

Control for routing in Leaflet
https://www.liedman.net/leaflet-routing-machine/
Other
1.08k stars 350 forks source link

WaypointReached and distance between points #496

Closed wadclapp closed 5 years ago

wadclapp commented 5 years ago

Hi

I've got a setup where the user can plot many markers, and then this gets routed with LRM.

I need to get the distance along the path (from the start) of either a coordinate on the path, or at least a waypoint/marker along the path, for multiple points. (for an elevation graph)

I tried looking for WaypointReached inside of the instructions like you mentioned in #196 and #253, but I'm not seeing it anywhere in the result?

Or is there a better solution available for doing this? Thanks

wadclapp commented 5 years ago

Nevermind, L.GeometryUtil solved the problem for me instead. Still not sure why WaypointReached isn't showing, maybe something specific to my setup.

perliedman commented 5 years ago

That is weird. Are you using OSRM as your routing backend? Could you share a set of waypoints that causes this?

wadclapp commented 5 years ago

Ah, using lrm-valhalla, happens for any route. Maybe a bit out of date. Only available solution I could find for using Valhalla.

Do you know if it's possible to easily modify Mapzen Valhalla (lrm-mapzen) for any provider? Mapzen has shutdown.

perliedman commented 5 years ago

@wadclapp not really sure, since they wrote it themselves, I never really checked the details. My guess is that the backend doesn't really use the WaypointReached instruction type - the code for that is backend specific, where the instructions returned by the backend is mapped to LRM's on instruction types. For some backends that can be tricky, since different backends use very different sets of instructions.

Any reason you want to stay with Valhalla and not switch to OSRM/Mapbox directions? From what I can tell, it looks like Mapbox is pushing development of Valhalla these days, but probably deliver it through their directions API.

wadclapp commented 5 years ago

The map provider I'm using uses Valhalla for routing, and Valhalla appears to do everything I need.

Are you suggesting OSRM is a better option? I couldn't really find much information on the major differences between them.