I am using the Google API Distance Matrix (mode 'driving') in an optimization program. If I run the program twice a day (e.g. in the morning and in the afternoon), I sometimes get different solutions. Since the Google API Distance Matrix is the only input besides my hard-coded input, I was wondering if the distance requests always return the same standardized distances or if the distances include current traffic etc. as well. Unfortunately I couldn't find anything that specific in the developers documentation.

Can somebody quickly answer my question?

Thanks in advance!


1 Answer 1


The distance depends on the shortest path, which further depends on the departure time from the origin. From the documentation of Distance API [1]

"Note: If departure time is not specified, choice of route and duration are based on road network and average time-independent traffic conditions. Results for a given request may vary over time due to changes in the road network, updated average traffic conditions, and the distributed nature of the service. Results may also vary between nearly-equivalent routes at any time or frequency."

[1] https://developers.google.com/maps/documentation/javascript/distancematrix

To get consistent results, I would advise specifying the departureTime parameter when calling the API.

  • $\begingroup$ Hi @Pramesh Kumar, thanks a lot! $\endgroup$
    – XLF
    Aug 22, 2022 at 13:52

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.