perliedman / leaflet-routing-machine

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

Getting timestamp for each LatLng coordinate in route #522

Closed daniel-bogdoll closed 5 years ago

daniel-bogdoll commented 5 years ago

Hey :)

I hope the title is clear, I need something like this (the question has been asked before, see below):

time | coordinates 1.37 | 47.99903 , 3.1699 1.50 | 47.99599, 3.17415

time = the time to get location

Originally posted by @gfoxx29 in https://github.com/perliedman/leaflet-routing-machine/issues/17#issuecomment-292563107

Your answer was to look at the instructions property. Unfortunately there are only some points listed, so an extra interpolation between the other points becomes necessary. Is there a way to retrieve this data directly? From my understanding it needs to be "somewhere" anyhow, since the instructions array has this information for a subset of points.

Thanks, Daniel

perliedman commented 5 years ago

The instructions are delivered from OSRM (the backend server), so Leaflet Routing Machine does not have more information on time/distance for intermediate points. AFAIK, you would have to calculate that information yourself, I do not think OSRM can provide it to you. Notice that just interpolation may be inaccurate, since the speed of the road might change between two instructions.