Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何从谷歌地图api获取流量导航持续时间?_Android_Google Maps - Fatal编程技术网

Android 如何从谷歌地图api获取流量导航持续时间?

Android 如何从谷歌地图api获取流量导航持续时间?,android,google-maps,Android,Google Maps,我想通过http请求从google maps api获取导航持续时间: 但是我得到了没有流量的持续时间。 如何获取流量的持续时间?从Google Directions API中,它指出: duration_in_traffic indicates the total duration of this leg, taking into account current traffic conditions. The duration in traffic will only be returned

我想通过http请求从google maps api获取导航持续时间:

但是我得到了没有流量的持续时间。
如何获取流量的持续时间?

从Google Directions API中,它指出:

duration_in_traffic indicates the total duration of this leg, taking into account current traffic conditions. The duration in traffic will only be returned if all of the following are true:

1.The directions request includes a departure_time parameter set to a value within a few minutes of the current time.
2.The request includes a valid Google Maps API for Work client and signature parameter.
3.Traffic conditions are available for the requested route.
4.The directions request does not include stopover waypoints.
因此,您需要满足上述所有要求,才能检索具有流量的持续时间


有关更多信息,您可以访问Google Directions API文档。

您现在无需高级帐户(只需启用“Google Maps Directions API”的标准API密钥),即可获得
流量中的持续时间。使用在浏览器中进行验证

https://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&departure_time=now&key=YOUR_KEY_HERE

javascript客户端似乎使用了另一个端点,该端点在\u流量中未返回
duration\u

请求必须满足以下条件,如中所更新:

  • 该请求包括一个出发时间参数
  • 请求包括有效的API密钥或有效的Google Maps API Premium Plan客户端ID和签名
  • 请求路线的交通条件可用
  • 该请求不包括中途停留航路点
  • 该请求专门针对行驶方向-模式参数设置为行驶

感谢您提出这一点:出发时间必须存在(即使其值为default=“now”)!