当您仅保存“纽约”搜索的结果时,请务必同时保存纬度/经度范围。
http://maps.google.com/maps/api/geocode/json?address=new%20york
边界在 JSON 中 results->geometry->bounds 下
{
"results" : [
{
"address_components" : [
{
"long_name" : "New York",
"short_name" : "NY",
"types" : [ "locality", "political" ]
},
{
"long_name" : "New York",
"short_name" : "NY",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "New York, NY, USA",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 40.91525559999999,
"lng" : -73.70027209999999
},
"southwest" : {
"lat" : 40.4913686,
"lng" : -74.25908989999999
}
},
"location" : {
"lat" : 40.7127837,
"lng" : -74.0059413
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 40.91525559999999,
"lng" : -73.70027209999999
},
"southwest" : {
"lat" : 40.4913686,
"lng" : -74.25908989999999
}
}
},
"types" : [ "locality", "political" ]
}
],
"status" : "OK"
}
现在,当您想查看“纽约中央公园”是否在“纽约”内时,请简单检查一下中央公园的纬度/经度是否大于西南边界,但小于东北边界。