Google 地图距离矩阵 API 给出了不可能短的 duration_in_traffic 结果,而且结果与 Google 地图不同

Google Maps Distance Matrix API gives impossibly short duration_in_traffic results and also the results are different than Google Maps

我正在向 Google 地图距离矩阵 API 发出请求,以获取 duration_in_traffic 今天下午在伊斯坦布尔两点 - 贝西克塔斯和博斯普鲁斯海峡大桥 - 之间的数据,我已经将出发时间设置为 17:00:00 2018 年 3 月 6 日。 returns 我认为需要 5 分钟,这实际上是不可能的,至少应该是 20 分钟。 Google 地图中的结果也不同。

这是我使用的 URL: https://maps.googleapis.com/maps/api/distancematrix/json?&departure_time=1520301600000&traffic_model=pessimistic&origins=41.045524,29.007519&destinations=41.050044,29.029765&key=MYKEY

这是 JSON 响应:

    {
   "destination_addresses" : [
      "Ortaköy Mh., İstanbul Çevre Yolu, 34347 Beşiktaş/İstanbul, Turkey"
   ],
   "origin_addresses" : [
      "Cihannüma Mahallesi, Barbaros Blv. No:76, 34353 Beşiktaş/İstanbul, Turkey"
   ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "3.1 km",
                  "value" : 3052
               },
               "duration" : {
                  "text" : "4 mins",
                  "value" : 217
               },
               "duration_in_traffic" : {
                  "text" : "5 mins",
                  "value" : 295
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}

Here's the Google Maps Screenshot for the specified time and destination

我不知道是什么原因造成的,但如果您能提供帮助,我将不胜感激。

您的出发时间以毫秒而不是秒为单位,这是距离矩阵 API 所采用的

https://developers.google.com/maps/documentation/distance-matrix/intro#departure-time

departure_time — The desired time of departure. You can specify the time as an integer in seconds since midnight, January 1, 1970 UTC. Alternatively, you can specify a value of now, which sets the departure time to the current time (correct to the nearest second).

此外,将出发时间转换为秒后,1520301600,日期实际上是 2018 年 3 月 6 日 0200 UTC,即当地时间凌晨 5 点,而不是下午 5 点。使用 1520517600,对应当地时间 2018 年 3 月 8 日下午 5 点,duration_in_traffic 为 18 分钟:

https://maps.googleapis.com/maps/api/distancematrix/json?departure_time=1520517600&traffic_model=pessimistic&origins=41.045524,29.007519&destinations=41.050044,29.029765&key=YOUR_KEY

{
   "destination_addresses" : [
      "Ortaköy Mh., İstanbul Çevre Yolu, 34347 Beşiktaş/İstanbul, Turkey"
   ],
   "origin_addresses" : [
      "Cihannüma Mahallesi, Barbaros Blv. No:76, 34353 Beşiktaş/İstanbul, Turkey"
   ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "3.1 km",
                  "value" : 3052
               },
               "duration" : {
                  "text" : "4 mins",
                  "value" : 217
               },
               "duration_in_traffic" : {
                  "text" : "18 mins",
                  "value" : 1081
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}