Reputation: 89
When adding a waypoint twice (as a starting point and as an end point of a route, the route is not displayed.
How to change the code so that it works?
L.Routing.control({
waypoints: [
L.latLng(lat1, long1),
L.latLng(lat2, long2),
L.latLng(lat1, long1,
],
serviceUrl: 'http://router.project-osrm.org/viaroute',
routeWhileDragging: false,
addWaypoints: false,
lineOptions: {
styles: [{color: 'black', opacity: 0.15, weight: 9}, {color: 'white', opacity: 0.8, weight: 6}, {color: 'orange', opacity: 1, weight: 2}]
}
Thanks
Upvotes: 1
Views: 1781
Reputation: 26
L.Routing.control({
waypoints: [
L.latLng(lat1, long1),
L.latLng(lat2, long2),
L.latLng(lat1, long1,
],
serviceUrl: 'http://router.project-osrm.org/viaroute',
routeWhileDragging: false,
addWaypoints: false,
lineOptions: {
styles: [{color: 'black', opacity: 0.15, weight: 9}, {color: 'white', opacity: 0.8, weight: 6}, {color: 'orange', opacity: 1, weight: 2}]
}
Your code needs a ) at the end of the last waypoint: L.latLng(lat1,long1) instead of L.latLng(lat1,long1,
Upvotes: 1