Is it possible to get directions in the past?

旧城冷巷雨未停 提交于 2021-01-29 11:09:17

问题


I am new to the Google Directions API, and I'm trying to get directions in the past (i.e. not today or any date/time in the future).

I have read about the arrival_time and departure_time parameters in the Developers Guide, and it says that you cannot choose a past date/time.

However, through the web interface, I can choose a prior date and time, and it appears to provide a different distance/time estimate than letting the website default to the current date/time.

This leads me to believe it is possible, but I have cannot figure out how to do it, either through the API or through a non-API structured URL.

Any help would be much appreciated!


回答1:


It is not possible to set departure_time in the past. Google's documentation states:

The departure_time must be set to the current time or some time in the future. It cannot be in the past.

Try the following Directions request (which has departure_time set to 10 July, i.e. 9 days ago as of today).

https://directionsdebug.firebaseapp.com/?origin=California%2C%20USA&destination=Las%20Vegas%2C%20NV%2C%20USA&mode=driving&departure_time=1562766180

You'll see this error:

Directions request failed due to INVALID_REQUEST - departure_time is in the past. Traffic information is only available for future and current times.

Hope this answers your question.



来源:https://stackoverflow.com/questions/57081566/is-it-possible-to-get-directions-in-the-past

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!