I'm using Leaflet Routing Machine in a litte Leaflet + Javascript map.
I'm using Graphhopper as router in this way ….
var control = L.Routing.control({
waypoints: [
L.latLng(57.74, 11.94),
L.latLng(57.6792, 11.949)
],
routeWhileDragging: true,
geocoder: L.Control.Geocoder.nominatim(),
router: L.Routing.graphHopper('a585904f-5193-4605-bc3c-870c4f472177' , {
urlParameters: {
vehicle: 'car'
}
})
}).addTo(map);
….. and all works fine
Now in my map I'd like to put give the opportunity to select, using a couple of buttons, the router "vehicle type", so if the user select "foot", I'd like to change the route vehicle parameter setting to 'foot' value.
How may I set this value? Something like
control.Router.?????? = 'foot'
Best Answer
To change the vehicle type, you would use:
However, the router does not automatically recalculate the route when you change the parameters, so to get the foot directions to show up, you will need to request it again: