Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. var routing1 = L.Routing.control({
  2. waypoints: [
  3. L.latLng(54.736038, 55.97429),
  4. L.latLng(54.736985, 55.980878),
  5. ],
  6. });
  7.  
  8. var routing2 = L.Routing.control({
  9. waypoints: [
  10. L.latLng(54.732798, 55.969934),
  11. L.latLng(54.734954, 55.95809)
  12. ],
  13. });
  14.  
  15. document.getElementById("drawing").addEventListener("click", myFunction);
  16. function myFunction() {
  17. routing1.addTo(map).on('routesfound', function (e) {
  18. distance = e.routes[0].summary.totalDistance;
  19. console.log('routing1 ' + distance);
  20. });
  21. routing2.addTo(map).on('routesfound', function (e) {
  22. distance = e.routes[0].summary.totalDistance;
  23. console.log('routing2 ' + distance);
  24. });
  25. }
  26.  
  27. var wayPoint1 = L.latLng(57.74, 11.94);
  28. var wayPoint2 = L.latLng(57.6792, 11.949);
  29.  
  30. var bounds = L.latLngBounds(wayPoint1, wayPoint2);
  31.  
  32. var myRouting = L.Routing.control({
  33. waypoints: [wayPoint1, wayPoint2],
  34. routeWhileDragging: true,
  35. show: false,
  36. createMarker: function(p1,p2) {}
  37. });
  38.  
  39. myRouting.on('routesfound', function (e) {
  40. distance = e.routes[0].summary.totalDistance;
  41. console.log('routing distance: ' + distance);
  42. });
  43.  
  44. // save original mathed for later use
  45. var _updateLines = myRouting._updateLines;
  46.  
  47. myRouting._updateLines = function (p1) { };
  48.  
  49. map.fitBounds(bounds);
  50. myRouting.onAdd(map);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement