如何在Google地图API中检查地区内的地址 [英] How to check if address in within region on Google Maps API
问题描述
我有一个地址字符串E.g. 新西兰旺格努伊Gonville 12瑞士大街12号
给出这个地址,我需要确定该地址是否位于新西兰北岛或南岛。 / p>
如果我将地址传递给google maps api,那么我得到的数据就在下面,不幸的是它并没有告诉我它在哪个岛上。我检查了这一点吗?
{
results:[
{
address_components :[
{
long_name:12,
short_name:12,
types:[
street_number
]
},
{
long_name:Swiss Avenue,
short_name:Swiss Ave,
types:[
路线
},
{
long_name:Gonville,
short_name:Gonville,
types:[
sublocality,
political
]
$ blong_name:Wanganui,
short_name:Wanganui,
types:[
locality ,
政治
long_name:Manawatu-Wanganui,
short_name:Manawatu-Wanganui ,
types:[
administrative_area_level_1,
political
]
},
{
long_name: 新西兰,
short_name:NZ,
types:[
country,
political
]
},
{
long_name:4501,
short_name:4501,
types:[
postal_code
]
}
],
formatted_address :新西兰Wanganui 4501 Gonville 12瑞士大街12号,
几何:{
location:{
lat:-39.9444245,
lng:175.0239575
},
location_type:ROOFTOP,
viewport:{
northeast:{
lat:-39.9430755197085 ,
lng:175.0253064802915
},
southwes t:{
lat:-39.9457734802915,
lng:175.0226085197085
}
}
},
types:[
street_address
}
],
status:OK
}
一个选项是获取两个岛的多边形,并在地理位置上进行多边形分析。
概念验证(使用Fusion Tables中的Natural Earth数据集和州到岛地图)
I have an address string E.g. "12 Swiss Ave, Gonville, Wanganui, New Zealand"
Given this address I need to work out if the address is within the North or South island of New Zealand.
If I pass the address to the google maps api the data I get back is below, unfortunately though it doesn't tell me what island it is in. So, how can I check this?
{
"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"
}
One option would be to get the polygons for the two islands and do point in polygon analysis on the geographic location.
Example using Polygons defined by KML and geoxml3
Proof of concept (using the Natural Earth data set in Fusion Tables and a "state to island" map)
这篇关于如何在Google地图API中检查地区内的地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!