2纬度与龙之间的行驶距离纬度、距离

2023-09-05 05:12:21 作者:糙汉子i

我在找计算出这两套纬度和长的距离上道路行驶。

我有看谷歌的方向和距离矩阵API。并且还做了很多其他问题上左右。

但我不能够找出最好的方式做到这一点,你需要计算在每个时间约20-25地点的距离。

我们正在建设一个旅游应用程序,需要这些信息在Android设备的用户从他在哪里。

解决方案

如果您正在寻找的行驶距离不是距离最短然后,您可以尝试调用API服务中包含的网址:

http://maps.googleapis.com/maps/api/distancematrix/json?origins=54.406505,18.67708&destinations=54.446251,18.570993&mode=driving&language=en-EN&sensor=false 今天常州的大风感受到了么 龙城通卡办理请错峰

这将导致JSON是这样的:

  {
   destination_addresses:PowstańcówWarszawy 8,索波特,波兰],
   origin_addresses:阴唇Henryka Sucharskiego 69,格但斯克,波兰],
   行:[
      {
         元素:
            {
               距离 : {
                  文:24.7公里,
                  值:24653
               },
               持续时间:{
                  文:34分钟,
                  值:2062
               },
               状态:OK
            }
         ]
      }
   ]
   状态:OK
}
 

结果距离是两个位置之间的实际道路距离。

您可以在在谷歌的距离矩阵API

I am looking to calculate and give the distance between two sets of Lat and Long for travel on Road.

I have had a look at the Google's Directions and Distance Matrix API. And also done a lot of other questions on SO.

But i am not able to figure out the best possible way to do it, you need to calculate the distance to around 20-25 locations at each time.

We are building a travel app that requires this information for the user on Android device from where he is.

解决方案

If You are looking for driving distance NOT shortest distance then You can try to call API service with URL like:

http://maps.googleapis.com/maps/api/distancematrix/json?origins=54.406505,18.67708&destinations=54.446251,18.570993&mode=driving&language=en-EN&sensor=false

This will result in JSON like this:

{
   "destination_addresses" : [ "Powstańców Warszawy 8, Sopot, Polska" ],
   "origin_addresses" : [ "majora Henryka Sucharskiego 69, Gdańsk, Polska" ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "24,7 km",
                  "value" : 24653
               },
               "duration" : {
                  "text" : "34 min",
                  "value" : 2062
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}

Result distance is actual road distance between two locations.

You can find more details in The Google Distance Matrix API