高德地图API-通过经纬度获取当前位置附近的建筑

一、需求说明

现在公司有一个新的需求,前端传入经纬度,后端计算出附近的医院、派出所等等,通过查阅高德地图的Web服务开发文档,找到了以下接口:

https://restapi.amap.com/v3/place/around?location=经纬度&key=web服务类型的key&keywords=派出所&types=130501&radius=5000&offset=20&page=1

二、这里是参数的介绍

参数
location逗号分割的经纬度,例如117.167688,27.469837
key创建的web类型的key 点击跳转去申请key
keywords周边搜索的关键词
types检索目标的分类(POI类型) 参考高德API官方文档
radius查询半径 0-50000
offset每一页返回查询结果的个数
page第几页

三、 接口返回结果

{
    "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"
                }
            ]
        }
    ]
}

四、代码分享

这里的HttpUtils和JSONObject都是Hutools工具包的,大家可以直接引入Hutools即可

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");
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

每天吃八顿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值