用高德地图API 通过详细地址获得经纬度

http://restapi.amap.com/v3/geocode/geo?key=xxxxxxxxxxxxxxxx&s=rsv3&city=35&address=福建省霞浦县水门畲族乡

 

String addressStr = "http://restapi.amap.com/v3/geocode/geo?key=xxxxxxxxxxxxxxxx&s=rsv3&city=028&address=";
        String getAddress = HttpUtils.get(addressStr + UrlEncoded.encodeString(address));
        JSONObject object = JSONObject.parseObject(getAddress);
        JSONArray geocodes = object.getJSONArray("geocodes");
        ExcelDetails details = ExcelDetails.dao.findById(id);
        if (geocodes.size() == 0) {
            details.set("status", 0);
        } else if (geocodes.size() == 1) {
            JSONObject trueAddress = geocodes.getJSONObject(0);
            String location = trueAddress.getString("location");
            String lngX = location.split(",")[0];
            String latY = location.split(",")[1];
        } else {
        }

你可能感兴趣的:(api)