Closed elangabdulazis closed 2 years ago
The plugin itself does not perform any distance calculation. The distance between the waypoints is returned by the respective routing api (i.e. OSRM).
If you just need the distance between two LatLngs, you could use Leaflet's builtin distanceTo function
can i apply a* algorithm to route finding in leaflet?
Not sure I get the question. Is it that you want to use your own routing provider? The plugin itself only uses different backend services and formats the returned waypoints. So if you want different results, you would either have to use a different routing provider or build your own (see osrmv1 for reference)
It would also help if you could share some code or runnable example, so I can understand what exactly is going on
I also want to ask how in the leaflet to get distance data?
I also want to ask how in the leaflet to get distance data?
See my first reply on how to use distanceTo for getting the distance between two LatLngs.
All this plugin does is request the distance data from an API of your choice and format it accordingly. It does not do any distance calculation itself.
If that is not your issue, please provide a code snippet or codesandbox/etc. that shows how your question is related to leaflet-routing-machine. Otherwise I can't accurately help you.
Hello all, I'm not sure if this is the right place to question this, but I believe it kinda relates so, here it is: Is there a method to access the private object _selectedRoute? I'm trying to get the summary from it because I will need to get the distance and duration of the selected route.
Thank you, Best regards
Let's say you have something like the following
const routingControl = L.Routing.control(...);
then you could do something along the lines of
const selectedRoute = routingControl._selectedRoute;
alternatively, you can provide your own _routeSelected implementation
const RoutingControl = L.Routing.Control.extend({
_routeSelected: function() {
// trigger some custom logic here to work with the selected route, then call the base implementation
}
});
This is supposing you use plain JavaScript though. If you're using Typescript, those types won't be available, unless you convert it to any or use a custom type
@elangabdulazis @tmbp95 Can I go ahead and mark this question as resolved?
Yes, thank you!
hi I want to ask if there is a distance calculation using a leaflet? because I need distance data from latitude 1,2,3 to finish