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'

..... 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'

To change the vehicle type, you would use:

control.getRouter().options.urlParameters.vehicle = 'foot';

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:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.