Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
- ],
- });
- 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);
- });
- }
- var wayPoint1 = L.latLng(57.74, 11.94);
- var wayPoint2 = L.latLng(57.6792, 11.949);
- var bounds = L.latLngBounds(wayPoint1, wayPoint2);
- var myRouting = L.Routing.control({
- waypoints: [wayPoint1, wayPoint2],
- routeWhileDragging: true,
- show: false,
- createMarker: function(p1,p2) {}
- });
- myRouting.on('routesfound', function (e) {
- distance = e.routes[0].summary.totalDistance;
- console.log('routing distance: ' + distance);
- });
- // save original mathed for later use
- var _updateLines = myRouting._updateLines;
- myRouting._updateLines = function (p1) { };
- map.fitBounds(bounds);
- myRouting.onAdd(map);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement