高德地图API使用(根据地址查经纬度,计算二个坐标之间的距离)

高德地图API使用(根据地址查经纬度,计算二个坐标之间的距离)
 
根据地址查经纬度:
https://restapi.amap.com/v3/geocode/geo?address=广西壮族自治区南宁市西乡塘区衡阳西路34号&output=JSON&key=38f05ba13d4324325
返回:

 

 

{
  "status": "1",
  "info": "OK",
  "infocode": "10000",
  "count": "1",
  "geocodes": [
    {
      "formatted_address": "广西壮族自治区南宁市西乡塘区衡阳西路34号",
      "country": "中国",
      "province": "广西壮族自治区",
      "citycode": "0771",
      "city": "南宁市",
      "district": "西乡塘区",
      "township": [],
      "neighborhood": {
        "name": [],
        "type": []
      },
      "building": {
        "name": [],
        "type": []
      },
      "adcode": "450107",
      "street": "衡阳西路",
      "number": "34号",
      "location": "108.304040,22.830050",
      "level": "门址"
    }
  ]
}

 

计算二个坐标之间的距离:
返回:
{
  "status": "1",
  "info": "OK",
  "infocode": "10000",
  "count": "1",
  "results": [
    {
      "origin_id": "1",
      "dest_id": "1",
      "distance": "6447",
      "duration": "1194"
    }
  ]
}

 

posted @ 2024-08-02 22:21  牛腩  阅读(239)  评论(0编辑  收藏  举报