我有一个地址字符串,例如“12 Swiss Ave, Gonville, Wanganui, New Zealand”
鉴于此地址,我需要确定该地址是在新西兰的北岛还是南岛之内。
如果我将地址传递给谷歌地图 api,我得到的数据如下,不幸的是,虽然它没有告诉我它在哪个岛。那么,我该如何检查呢?
{
"results": [
{
"address_components": [
{
"long_name": "12",
"short_name": "12",
"types": [
"street_number"
]
},
{
"long_name": "Swiss Avenue",
"short_name": "Swiss Ave",
"types": [
"route"
]
},
{
"long_name": "Gonville",
"short_name": "Gonville",
"types": [
"sublocality",
"political"
]
},
{
"long_name": "Wanganui",
"short_name": "Wanganui",
"types": [
"locality",
"political"
]
},
{
"long_name": "Manawatu-Wanganui",
"short_name": "Manawatu-Wanganui",
"types": [
"administrative_area_level_1",
"political"
]
},
{
"long_name": "New Zealand",
"short_name": "NZ",
"types": [
"country",
"political"
]
},
{
"long_name": "4501",
"short_name": "4501",
"types": [
"postal_code"
]
}
],
"formatted_address": "12 Swiss Avenue, Gonville, Wanganui 4501, New Zealand",
"geometry": {
"location": {
"lat": -39.9444245,
"lng": 175.0239575
},
"location_type": "ROOFTOP",
"viewport": {
"northeast": {
"lat": -39.9430755197085,
"lng": 175.0253064802915
},
"southwest": {
"lat": -39.9457734802915,
"lng": 175.0226085197085
}
}
},
"types": [
"street_address"
]
}
],
"status": "OK"
}