Google Maps Directions API duration_in_traffic与maps.google.com不同

时间:2016-07-31 23:48:46

标签: google-maps

使用路线api(https://developers.google.com/maps/documentation/directions/)并提供出发时间。这给了我一个duration_in_traffic响应。 但是,我在回复中的时间远低于我在maps.google.com上看到的相同路线和时间请求的时间。

我应该做一个时区转换吗?我正在使用javascript getTime()函数为请求的出发时间提供开始时间

1 个答案:

答案 0 :(得分:0)

找到解决方案。我使用getTime javascript函数将departure_time发送到API。但Directions API期望以秒为单位的时间,并且getTime以毫秒为单位给我。所以我所要做的就是把它除以1000,现在我得到了可靠的答案