| | |
| | | * @throws Exception |
| | | */ |
| | | public static Map<String, String> geocode(String lon, String lan) throws Exception { |
| | | |
| | | System.out.println(lon+"_"+lan+"!!!!!!!!!!!!!!!!"); |
| | | String url = "https://restapi.amap.com/v3/geocode/regeo?key=" + key + "&location=" + lon + "," + lan; |
| | | String forObject = HttpUtils.sendGet(url); |
| | | JSONObject jsonObject = JSON.parseObject(forObject); |
| | |
| | | String province = addressComponent.getString("province"); |
| | | String city = addressComponent.getString("city"); |
| | | String district = addressComponent.getString("district"); |
| | | System.out.println(code+"#######################"); |
| | | map.put("province", province); |
| | | map.put("provinceCode", code.substring(0, 2) + "0000"); |
| | | map.put("city", city); |
| | |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | Map<String, String> geocode = geocode("140.0136050", "19.51689069"); |
| | | |
| | | } |
| | | } |