高德地图API-通过经纬度获取当前位置附近的建筑
现在公司有一个新的需求,前端传入经纬度,后端计算出附近的医院、派出所等等,通过查阅高德地图的Web服务开发文档,发现了以下接口:
https://restapi.amap.com/v3/place/around?location=经纬度&key=web服务类型的key&keywords=派出所&types=130501&radius=5000&offset=20&page=1
这里是参数的介绍
这里是返回的结果
{
          
   
    "status": "1",
    "info": "OK",
    "infocode": "10000",
    "count": "1",
    "suggestion": {
          
   
        "keywords": [],
        "cities": []
    },
    "pois": [
        {
          
   
            "id": "B025705MII",
            "parent": [],
            "childtype": [],
            "name": "止马镇中心卫生院",
            "type": "医疗保健服务;综合医院;卫生院",
            "typecode": "090102",
            "biz_type": [],
            "address": "止马镇止马中路1号",
            "location": "117.169901,27.471023",
            "tel": "0599-7771221;0599-7772778",
            "pname": "福建省",
            "cityname": "南平市",
            "adname": "光泽县",
            "importance": [],
            "shopid": [],
            "shopinfo": "2",
            "poiweight": [],
            "distance": "255",
            "biz_ext": {
          
   
                "rating": [],
                "cost": []
            },
            "photos": [
                {
          
   
                    "title": [],
                    "url": "http://store.is.autonavi.com/showpic/beceaa81b666376821c4c7819160742a"
                }
            ]
        }
    ]
} 
这里是从返回的json中拿名称、经纬度和电话的代码
String resultStr = HttpUtils.get("https://restapi.amap.com/v3/place/around?location=" + location + "&key=你的key&keywords=派出所&types=130501&radius=5000&offset=20&page=1");
JSONObject resultJson = JSONObject.parseObject(resultStr);
JSONArray pois = resultJson.getJSONArray("pois");
String tel = pois.getJSONObject(0).getString("tel");
String name= pois.getJSONObject(0).getString("name");
String location= pois.getJSONObject(0).getString("location");
				       
			          
