简体   繁体   English

如何使用Google Distance Matrix API获取总行驶距离?

[英]How to get the total driving distance with Google Distance Matrix API?

I have an array of lat/lng. 我有一个经纬度数组。 Example: 例:

[
  "14.60592,103.12081",
  "38.21146,114.86461",
  "13.73028,100.65138",
  "34.08863,108.39783",
  "57.186,14.04"
]

How can I calculate the overall distance from A to B and from B to C. 如何计算从A到B以及从B到C的总距离。

I trying with the Google Distance Matrix API. 我尝试使用Google Distance Matrix API。

If you need driving distance then you will not be able to calculate it with any formula not knowing the terrain, roads etc. For example if there is a river between those two points then the driving distance will depend on where is the closest bridge. 如果需要行驶距离,则将无法使用不知道地形,道路等的任何公式来进行计算。例如,如果这两点之间有一条河流,那么行驶距离将取决于最近的桥梁在哪里。

You can use some API that has that knowledge and can give you a real driving distance. 您可以使用一些具有该知识的API,并且可以为您提供真实的行驶距离。 For example you can use the Google Maps API. 例如,您可以使用Google Maps API。 See eg Distance Matrix API: 参见例如距离矩阵API:

You can use the Google Maps API in Node with: 您可以在以下节点中使用Google Maps API:

and some more - see: 还有更多-请参阅:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM