/**
* 中文地址解析为经纬度
*
* @param address
* @return
*/
public ResponseResult<RegeoModel> regeo(String address) {
ResponseResult<RegeoModel> result = new ResponseResult<>();
result.setStatus(-1);
try {
String url = "https://apis.map.qq.com/ws/geocoder/v1/?address=";
URIBuilder urlBuilder = new URIBuilder(url);
urlBuilder.addParameter("address", address);
urlBuilder.addParameter("key", key);
HttpGet httpGet = new HttpGet(urlBuilder.build());
HttpResponse httpResponse = httpClient.execute(httpGet);
if (validHttpStatusCode(httpResponse)) {
result.setStatus(ResponseResult.status_success);
String response = EntityUtils.toString(httpResponse.getEntity());
logger.debug("", response);
JSONObject map = JSONObject.parseObject(response);
if (map.getInteger("status") == 0) {
JSONObject resultData = map.getJSONObject("result");
RegeoModel regeoModel = new RegeoModel();
JSONObject location = resultData.getJSONObject("location");
regeoModel.setLng(location.getBigDecimal("lng"));
regeoModel.setLat(location.getBigDecimal("lat"));
JSONObject addressComponents = resultData.getJSONObject("address_components");
regeoModel.setProvince(addressComponents.getString("province"));
regeoModel.setCity(addressComponents.getString("city"));
regeoModel.setDistrict(addressComponents.getString("district"));
regeoModel.setStreet(addressComponents.getString("street"));
JSONObject adInfo = resultData.getJSONObject("ad_info");
if (adInfo != null && adInfo.get("adcode") != null) {
regeoModel.setAdCode(adInfo.getString("adcode"));
}
result.setData(regeoModel);
return result;
} else {
result.setStatus(map.getInteger("status"));
lo
检查地图坐标系是否统一