-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get distance problem #150
Comments
Hi, I had the same prob and solved it with this: window.L.Routing.control({
Where coordinates is an array => Hope it helps. |
@Doeran like many things in JavaScript, the routing is asynchronous. Calling You should probably use events to solve this. If you want to catch resulting routes when they are returned to the control for example, you should listen to the routeControl.on('routesfound', function(e) {
var routes = e.routes;
[...]
}); If you're interested in every time the user selects a route, the Lastly, if you're not really interested in the UI, you could go with @SamSalman's solution above. |
thank you a lot @perliedman. |
i have the following code
var routeControl = L.Routing.control({
createMarker : function() {
return null;
}
}).addTo(map);
var routee = new Array(); // array of latlng data
for (var i = 0; i < markersArray.length; i++)
routee.push(new L.LatLng(markersArray[i][0],
markersArray[i][1]));
routeControl.setWaypoints(routee);
but when i try get distance
routeControl._routes[0].summary.totalDistance
I get an error:
typeerror cannot read property 0 of undefined
Can you help me to fix this?
The text was updated successfully, but these errors were encountered: