dimanche 22 mars 2015

leaflet-routing-machine add waypoints, routing summary


I'm playing around with leaflet-routing-machine (http://ift.tt/1nLv52K) and have 2 questions about it's usage:


1)


I have the following code now



routeControl = L.Routing.control({
waypoints: [
L.latLng(48.133205,11.565225),
L.latLng(48.131830,11.588227)
],
useZoomParameter: false,
autoRoute: false,
}).addTo(map);


which works fine, but what when i want to start without any waypoints? When i leave out the waypoints from the constructor and try to add it then with



routeControl.spliceWaypoints(0, 0, e.latlng);


routing is not working anylonger (i know, i need to start routing manually, because I set autoRoute to false). But if I start with those initial points and add further waypoints, routing is working.


2) I'm trying to get totalDistance, which is part of the Interface IRouteSummary.


According to the API, I need to access the IRoute Interface, but i didn't find out how to get IRoute from L.Routing.Control


I found this post (http://ift.tt/1DOwrEv) which uses an array of routes[], but i also don't know how to get this array?! It also refers to this Tutorial http://ift.tt/1CMWy22 but here i don't find any information about how to access this array as well.





1 commentaire: