2纬度与龙之间的行驶距离 [英] Travel Distance between two Lat and Long

查看:132
本文介绍了2纬度与龙之间的行驶距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

解决方案

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

<$p$p><$c$c>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

这篇关于2纬度与龙之间的行驶距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆