I am using LRM to calculate routes. And I need data about this routes. Now I'm just learning how to exctract this data so I can use it further. I have two routes
var routing1 = L.Routing.control({
waypoints: [
L.latLng(54.736038, 55.97429),
L.latLng(54.736985, 55.980878),
],
});
var routing2 = L.Routing.control({
waypoints: [
L.latLng(54.732798, 55.969934),
L.latLng(54.734954, 55.95809)
],
});
I have a button to draw this routes
document.getElementById("drawing").addEventListener("click", myFunction);
function myFunction() {
routing1.addTo(map).on('routesfound', function (e) {
distance = e.routes[0].summary.totalDistance;
console.log('routing1 ' + distance);
});
routing2.addTo(map).on('routesfound', function (e) {
distance = e.routes[0].summary.totalDistance;
console.log('routing2 ' + distance);
});
}
As I don't quite understand JS yet so I have this question:
How can I console.log route's summary the moment route calculated? Without drawing it.
routing1.on('routesfound', function (e){}doesn't work (and I think it should but maybe I'm missing something) - indeedme