Skip to content
Advertisement

Google Directions API don’t consider depature dates for temporarily closed routes

I want to use the directions API from Google Maps to get a route between two waypoints.

For example take these two:

  • Barcelonnette, 04400, France
  • Cime de la Bonette, 04850 Jausiers, France

There is a temporarily closed route between those waypoints, if I change the destination date in Google Maps to 2022-02-25, the route is used (which is correct, cause it is opened than).

If I try to get the same result with directions API, with this payload

{
  key: 'xxx',
  origin: 'place_id:ChIJPW2q1MfszBIRRpzUj4a7mFE',
  destination: 'place_id:ChIJGVSqBcnxzBIRMQdNNe4usKw',
  alternatives: true,
  mode: 'driving',
  language: 'de',
  departure_time: 1645803229
}

I only get the longer route, that I also get in Maps with date 2022-01-03.

Is there any other way to get the API to recognize my date?

Advertisement

Answer

We did some further checks and it seemed to be only an error in our implementation. It’s important to send the departure_time in seconds and not in milliseconds, as for example javascripts getTime() method provide them. In the same time we are testing this change, the opening days of the route had changed and let’s us think that this change did not solve the issue.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement