perliedman / leaflet-routing-machine

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

How can I put in each point of the route the time it takes and the current distance? as well as the distance or remaining time? #656

Open fermabo opened 2 years ago

fermabo commented 2 years ago

For now I have only found a way to obtain it by the full path not by each point.

var routeControl = L.Routing.control({...}); ... routeControl.on('routesfound', function(e) { var routes = e.routes; var summary = routes[0].summary; // alert distance and time in km and minutes alert('Total distance is ' + summary.totalDistance / 1000 + ' km and total time is ' + Math.round(summary.totalTime % 3600 / 60) + ' minutes'); });