如何从谷歌地图方向api获得总旅行距离和路线,如优步 [英] How to get total travelled distance and route from google map directions api like uber
问题描述
如何从Google地图方向API获取总旅行距离和路线,以
显示用户像Uber一样走过的路径。 您可以使用 矩阵/介绍rel =nofollow noreferrer> Google Maps Distance Matrix API ,它为原点和目的地矩阵提供行程距离和时间。它根据Google Maps API计算的开始点和结束点之间建议的路线返回信息,并且包含包含每对的持续时间和距离值的行。
Google Maps Distance Matrix API请求采用以下格式:
https://maps.googleapis.com/maps/api/distancematrix/outputFormat?parameters
其中 outputFormat
可以是以下任一值:
$ b
这里还有一些相关的SO问题:
>
希望这有助于!
How to get total travelled distance and route from google map directions API to show user travelled path like Uber.
You can use the Google Maps Distance Matrix API that provides travel distance and time for a matrix of origins and destinations. It returns information based on the recommended route between start and end points, as calculated by the Google Maps API, and consists of rows containing duration and distance values for each pair.
A Google Maps Distance Matrix API request takes the following form:
https://maps.googleapis.com/maps/api/distancematrix/outputFormat?parameters
where outputFormat
may be either of the following values:
- json (recommended), indicates output in JavaScript Object Notation (JSON); or
- xml, indicates output as XML.
Check this example from GitHub. The tutorial finds the distance and time taken to travel in driving mode and by avoiding tolls from origin to destination using Google Maps Distance Matrix API.
Here also are some related SO questions:
- How to get total driving distance with Google Maps API V3?
- Using Google Maps API to get travel time data
Hope this helps!
这篇关于如何从谷歌地图方向api获得总旅行距离和路线,如优步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!