2
votes

I would like to get the distance between 2 markers but not as a direct line, more as a real path like it goes in this plugin -

https://github.com/perliedman/leaflet-routing-machine

I didn't find anything about using this plugin in the directive: angular-leaflet-directive, if someone can guide how to make it done, it would be very appreciated.

thanks!

1

1 Answers

0
votes

I am not sure if you specifically want to use leaflet routing machine to get distances... but if you do, maybe this info can get you started:

Set up a route on your map based on this example by the leaflet routing machine author:

https://www.liedman.net/leaflet-routing-machine/tutorials/interaction/

If you look at that example, there is an array called routes. Each route has some basic statistics associated with it, generated by OSRM. You can pull them by calling for example:

routes[0].summary.totalDistance

or

routes[0].summary.totalTime

Then you can do whatever you want with them. If you dig through the code on GitHub you can see more about how the data are moved around within the plugin and why the array is arranged that way:

https://unpkg.com/[email protected]/dist/leaflet-routing-machine.js