Andriod通过经纬度解析实际地址

public static String getAddress(double latitude, double longitude){
		String address = "";
		String url = "http://maps.google.cn/maps/api/geocode/json?latlng=" + latitude + "," + longitude + "&sensor=true,language=zh-CN";
		JSONObject obj = httpGet(url);
		try {
			if (obj.getString("status").equals("OK")){
				JSONArray ja = JSON.parseArray(obj.getString("results"));
				JSONObject jo = JSON.parseObject(ja.getString(0));
				address = jo.getString("formatted_address");
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return address;
	}

得到的结果是

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "三星河西路",
               "short_name" : "三星河西路",
               "types" : [ "route" ]
            },
            {
               "long_name" : "启东市",
               "short_name" : "启东市",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "南通市",
               "short_name" : "南通市",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "江苏省",
               "short_name" : "江苏省",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "中国",
               "short_name" : "CN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "中国江苏省南通市启东市三星河西路",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 31.80471519999999,
                  "lng" : 121.5974265
               },
               "southwest" : {
                  "lat" : 31.8010305,
                  "lng" : 121.5947618
               }
            },
            "location" : {
               "lat" : 31.8028837,
               "lng" : 121.5960734
            },
            "location_type" : "GEOMETRIC_CENTER",
            "viewport" : {
               "northeast" : {
                  "lat" : 31.80471519999999,
                  "lng" : 121.5974431302915
               },
               "southwest" : {
                  "lat" : 31.8010305,
                  "lng" : 121.5947451697085
               }
            }
         },
         "place_id" : "ChIJp4KxuQ_9sTURgjlmYR-EVdk",
         "types" : [ "route" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "启东市",
               "short_name" : "启东市",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "南通市",
               "short_name" : "南通市",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "江苏省",
               "short_name" : "江苏省",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "中国",
               "short_name" : "CN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "中国江苏省南通市启东市",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 32.1230276,
                  "lng" : 121.9751853
               },
               "southwest" : {
                  "lat" : 31.6170391,
                  "lng" : 121.4314881
               }
            },
            "location" : {
               "lat" : 31.793278,
               "lng" : 121.655432
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 32.1230276,
                  "lng" : 121.9751853
               },
               "southwest" : {
                  "lat" : 31.6170391,
                  "lng" : 121.4314881
               }
            }
         },
         "place_id" : "ChIJe2KEZhUcrjURttkD8epMbU4",
         "types" : [ "political", "sublocality", "sublocality_level_1" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "南通市",
               "short_name" : "南通市",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "江苏省",
               "short_name" : "江苏省",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "中国",
               "short_name" : "CN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "中国江苏省南通市",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 32.7111345,
                  "lng" : 121.9751853
               },
               "southwest" : {
                  "lat" : 31.6170391,
                  "lng" : 120.2023156
               }
            },
            "location" : {
               "lat" : 31.980171,
               "lng" : 120.894291
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 32.1232631,
                  "lng" : 121.0250473
               },
               "southwest" : {
                  "lat" : 31.9006504,
                  "lng" : 120.7256162
               }
            }
         },
         "place_id" : "ChIJC-ohLkd4sTURVqJkkGIKJZY",
         "types" : [ "locality", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "江苏省",
               "short_name" : "江苏省",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "中国",
               "short_name" : "CN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "中国江苏省",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 35.1245133,
                  "lng" : 121.9751853
               },
               "southwest" : {
                  "lat" : 30.7578404,
                  "lng" : 116.3619603
               }
            },
            "location" : {
               "lat" : 33.1401715,
               "lng" : 119.7889248
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 35.124353,
                  "lng" : 121.962778
               },
               "southwest" : {
                  "lat" : 30.7578404,
                  "lng" : 116.3619603
               }
            }
         },
         "place_id" : "ChIJRcJLMdoAtzURtVOFbLbqlI0",
         "types" : [ "administrative_area_level_1", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "中国",
               "short_name" : "CN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "中国",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 53.56097399999999,
                  "lng" : 134.7728099
               },
               "southwest" : {
                  "lat" : 17.9996,
                  "lng" : 73.4994136
               }
            },
            "location" : {
               "lat" : 35.86166,
               "lng" : 104.195397
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 53.56097399999999,
                  "lng" : 134.7726951
               },
               "southwest" : {
                  "lat" : 18.1618062,
                  "lng" : 73.5034261
               }
            }
         },
         "place_id" : "ChIJwULG5WSOUDERbzafNHyqHZU",
         "types" : [ "country", "political" ]
      }
   ],
   "status" : "OK"
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值