最近的项目要求将详细地址的经纬度取出,不一定是自己的位置定位,也可能是别人的,只要输入一个详细的地址就会
获取到对应的经纬度,最好能够有像是地图里输入相关信息出现关联地址列表的界面,点击列表中的条目返回对应的经纬度值,没有怎么做过求大神指导
参考:http://www.cnblogs.com/exmyth/p/4423769.html
http://restapi.amap.com/v3/geocode/geo?key=xxxxxxxxxxxxxxxx&s=rsv3&city=35&address=福建省霞浦县水门畲族乡
可用key=389880a06e3f893ea46036f030c94700测试
http://webapi.amap.com/maps?v=1.1&key=389880a06e3f893ea46036f030c94700
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 {
}