【问题标题】:how to get coordiantes in response instead of origin & destination addresses in Google Map Distance Matrix API如何在 Google Map Distance Matrix API 中获取坐标而不是起点和终点地址
【发布时间】:2019-07-16 06:15:06
【问题描述】:

我在我的 android 应用程序中使用谷歌距离矩阵 api。我通过将起点和终点发送到 API 来调用 Google 距离矩阵 api。

API 返回响应为:

{
   "destination_addresses" : [ "Islamabad, Islamabad Capital Territory, Pakistan" ],
   "origin_addresses" : [ "Lahore, Punjab, Pakistan" ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "234 mi",
                  "value" : 376505
               },
               "duration" : {
                  "text" : "4 hours 20 mins",
                  "value" : 15608
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}

我想获取目的地和起点坐标而不是位置地址。

(我需要坐标进行比较)

是否有获取坐标的选项,或者您能否推荐一些其他第三方库来获得我想要的响应。

【问题讨论】:

    标签: android google-maps google-distancematrix-api distance-matrix


    【解决方案1】:

    获得 address 后,使用 GeoCoding Api 进行另一个 api 调用。它将像这样返回 lat long

    https://maps.googleapis.com/maps/api/geocode/json?address=YOUR_LOCATION&key=YOUR_API_KEY
    

    Geocoding API

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-31
      • 2017-10-06
      • 1970-01-01
      相关资源
      最近更新 更多