How can I prevent the results from the Google Maps API v3 DirectionsService from influencing the current traffic conditions?

I wrote a website that uses the Google Maps v3 DirectionsService API to find the distance between two user-defined points.

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

For example, I traveled between Coatbridge and Grangemouth twice the first time, when he told me that the distance is 41.8 km, the second time he said that it is 39.9 km.

I suspect this may affect current traffic conditions, perhaps. I did not find any hints in the google documentation.

Anyone else run into this issue? More importantly, does anyone have a solution?

Edit:
It seems that the influence of the current traffic conditions is a well-known "function" of Google Maps DirectionsService (thanks for your input @vitors), but so far no one has suggested a method to "disable" this function.

How can I prevent the impact of the results on current traffic conditions? Can someone help please?

Edit: It seems that Google has finally added a durationInTraffic parameter (thanks for the @Ron info). Shame on me for almost 2 years is too late for me! Hope this is helpful to someone else.

+4
source share
3 answers

You can try setting durationInTraffic as false.

+1
source

Your suspicion is correct, the traffic conditions influence the result.

I think this post may explain http://searchengineleland.com/traffic-estimates-return-to-google-maps-116862.

0
source

If you want to provide the user with only one point, and this should be the shortest distance that you can do, specify the optimizeWaypoints parameter (optional) when calling the distance service for Google. After using this parameter, the first result in the array that you get will contain your shortest distance and will always be the same:

For more information, you can follow this link: https://developers.google.com/maps/documentation/javascript/directions

and search for optimization points

Happy coding.

0
source

Source: https://habr.com/ru/post/1434871/


All Articles