Alternative routes

hey i use javascript and i am trying to display alternative routes but i get 400 error.
my code:

orsDirections.calculate({
        coordinates: [[21.78896,40.30069], [22.933332, 39.366669]],
        profile: "driving-car",
        alternative_routes:{"target_count":3,"weight_factor":2,"share_factor":2},
        extra_info: ["waytype", "steepness"],
        options: {avoid_features :["highways"]},
        format: "geojson",
        api_version: 'v2',
      })

am i missing something?

Hi @George_Kampouris,

what does the response say?

400 bad request

Hey,

can you give the complete response? Usually, the openrouteservice should offer a bit more information on what is going wrong.

Other than that, there’s two things I can see being the problem:

  1. please also enclose avoid_features in double quotes
  2. you can only call for alternative routes if your route is estimated to be less than 100km long, which is not the case here.

Best regards

ok thank a lot. the problem was that the route was more than 100km

1 Like