Java后台调用的高德api,通过经纬度查询地址信息
官方文档地址:/api/webservice/guide/api/georegeo
传入的参数为location,location:经度,纬度
输出为json字符串
/*** 调用地图api,通过location查询areaAdcode* @param params* @return* @throws Exception*/public static Map<String,String> findAdressByLocation(String location) throws Exception {Map<String, String> resuleMap = new HashMap<>();String areaAdcode = null;String accessAddress = null;String key ="3898**************94700";String apiurl = "/v3/geocode/regeo?location="+ location +"&poitype=&key="+ key +"&radius=1000&extensions=all&batch=false&roadlevel=0";String result = HttpUtils.httpsGetRequest(apiurl);JSONObject jsonObj = new JSONObject().fromObject(result);if(jsonObj.getInt("status") == 1){JSONObject regeocodes = jsonObj.getJSONObject("regeocode");JSONObject addressComponent = regeocodes.getJSONObject("addressComponent");areaAdcode = addressComponent.getString("adcode");accessAddress = regeocodes.getString("formatted_address");resuleMap.put("areaAdcode", areaAdcode);//行政编码resuleMap.put("accessAddress", accessAddress);//地址}else{resuleMap.put("areaAdcode", areaAdcode);resuleMap.put("accessAddress", accessAddress);resuleMap.put("code", "500");resuleMap.put("message", "高德api查询异常!");return resuleMap;}resuleMap.put("code", "200");resuleMap.put("message", "调用高德api成功!");return resuleMap;}
如果觉得《Java调用的高德api 通过经纬度查询地址信息 - 记录》对你有帮助,请点赞、收藏,并留下你的观点哦!