leaflet-routing-machine add waypoints, routing summary

المشرف العام

Administrator
طاقم الإدارة
I'm playing around with leaflet-routing-machine (https://github.com/perliedman/leaflet-routing-machine) 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://stackoverflow.com/questions/26570980/getting-distance-between-2-markers) which uses an array of routes[], but i also don't know how to get this array?! It also refers to this Tutorial http://www.liedman.net/leaflet-routing-machine/tutorials/interaction/ but here i don't find any information about how to access this array as well.



أكثر...
 
أعلى