0

I have a leaflet map, using graphopper as the router. I'm having problems with setting the options; for instance change the vehicle from default (car) to motorcycle.

routeControl = new L.Routing.Control({
    waypoints: setWaypoints,
    show: false,
    routeWhileDragging: true,
    router: L.Routing.graphHopper("api key"),
    vehicle: "motorcycle"
}).addTo(map);

Any help in the right direction is much appreciated.

Jieter
  • 4,101
  • 1
  • 19
  • 31
Kenneth Breugelmans
  • 501
  • 1
  • 8
  • 22

1 Answers1

1

I was able to solve the problem by using;

routeControl.getRouter().options.urlParameters.vehicle = 'motorcycle'; routeControl.route();

after it was added to the map. Apparently motorcycle is not included in the free account but this approach works for the car, foot and bike.

I was wondering if there is a better solution for implementing this, because this way takes an extra step.

Kenneth Breugelmans
  • 501
  • 1
  • 8
  • 22