Search code examples
google-mapsgoogle-maps-api-3driving-directions

How can I prevent the results produced by Google Maps API v3 DirectionsService being influenced by current traffic conditions?


I have written a website that uses the DirectionsService of Google Maps API v3 to find the driving distance between two user-defined locations.

I have found that it produces different results at different times of day or different days of the week.

For example, I have run a journey between Coatbridge and Grangemouth on two separate occasions the first time it told me the distance was 41.8km, the second time it said it was 39.9km.

I suspect it could be influenced by current traffic conditions, perhaps. I have found no clues within the Google documentation.

Has anyone else come across this problem? More importantly, does anyone have a solution?

Edit:
It seems that the influence of current traffic conditions is a known 'function' of the Google Maps DirectionsService (thanks for your input @vitors), but, as yet, no one has come forward with a method to 'turn off' this functionality.

How can I prevent the results being influenced by current traffic conditions? Can anyone help, please?

Edit: It seems Google have finally added a durationInTraffic parameter (thanks for the info @Ron). Shame it's nearly 2 years too late for me! Hope this is useful for someone else.


Solution

  • You could try setting durationInTraffic as false.