Search code examples
google-directions-api

Is Travel time considered without the OPTIMIZED field being set to true?


Our service is wanting a consistent result when selecting a route based on various factors. We simply are looking to understand if there is any order to the resulting routes in the response. Specifically whether or not travel time dictates that order.

TL;DR - does routes[0] always return the same route & travel distance value at any time of the day (assuming no new roads or routes were added during that time and traffic/ETA is the only variable)

We try taking routes[0] and were assuming a consistent result being returned throughout the day. We discovered that this may possibly change based on the travel time defined in the route, but also found that in the documentation this may or may not be included by default, or only if the optimized param is set to true.


Solution

  • This is explained in the departure_time documentation.

    Except for very short or simple routes, consistent routing is not guaranteed; the route/s returned will depend on the value provided as departure_time, also when there no departure_time.