问题
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