Google 路线 API 交通持续时间

Google Directions API Duration In Traffic

我在使用 Google 路线 API Web 服务时注意到,当请求包含超过 1 条路段时,响应不包括交通信息中的持续时间。对于 1 条路段请求,响应中会显示交通持续时间。这是为什么?

 https://maps.googleapis.com/maps/api/directions/json?origin=50.7963874022473,-1.12215042114258&destination=50.8525337185711,-1.17932204157114&waypoints=50.7921245679458,-1.13072438976753&mode=driving&departure_time=1452940200&traffic_model=pessimistic&units=imperial&key=myKey

在上面的请求中没有 Duration in traffic 但在下面的请求中

https://maps.googleapis.com/maps/api/directions/json?origin=50.7963874022473,-1.12215042114258&destination=50.8525337185711,-1.17932204157114&mode=driving&departure_time=1452940200&traffic_model=pessimistic&units=imperial&key=myApi

存在持续时间 In Traffic。

您可以在 waypoints 前加上 via:,这将 return 仅包含一条路段的响应,并在流量字段中包含持续时间。(只要包含正确的参数)。

 https://developers.google.com/maps/documentation/directions/intro?hl=en