获取给定邮政编码的最佳位置是什么?它适用于美国/加拿大以外的国家。谢谢
答案 0 :(得分:6)
使用Google地理定位API(在google.com/maps上试用):
输入瑞士邮政编码,例如: CH-9014
或法国人: FR-34000
或德语: 解12101
或美国: US-90210
或加拿大: ca-J5Z 1A1
或中国: CN-100000
for example:
产量
{
"status": "OK",
"results": [ {
"types": [ "postal_code" ],
"formatted_address": "9014 St Gallen, Switzerland",
"address_components": [ {
"long_name": "9014",
"short_name": "9014",
"types": [ "postal_code" ]
}, {
"long_name": "St Gallen",
"short_name": "St Gallen",
"types": [ "locality", "political" ]
}, {
"long_name": "Sankt Gallen",
"short_name": "SG",
"types": [ "administrative_area_level_1", "political" ]
}, {
"long_name": "Switzerland",
"short_name": "CH",
"types": [ "country", "political" ]
} ],
"geometry": {
"location": {
"lat": 47.4082855,
"lng": 9.3323890
},
"location_type": "APPROXIMATE",
"viewport": {
"southwest": {
"lat": 47.3991076,
"lng": 9.3180504
},
"northeast": {
"lat": 47.4199564,
"lng": 9.3543340
}
},
"bounds": {
"southwest": {
"lat": 47.3991076,
"lng": 9.3180504
},
"northeast": {
"lat": 47.4199564,
"lng": 9.3543340
}
}
}
} ]
}
所以瑞士邮政编码9014对应appx。到这个位置:
"lat": 47.4082855,
"lng": 9.3323890
请在此处查看我对地理定位API的回答:
How to get GLatLng object from address string in advance in google maps?
答案 1 :(得分:1)
GeoNames提供多种邮政编码地理编码服务,包括搜索给定邮政编码的位置。他们支持许多不同的国家。
最感兴趣答案 2 :(得分:1)
Google的API附带了一些相当令人讨厌的限制。根据@Claus Broch的建议,最好使用像GeoNames这样的开源。
我正在添加这个答案还要注意MapQuest最近为OpenStreetMap数据提供了一个API。它没有(据我所知)邮政编码搜索,但位置名称,方向,高度等都可以自由查询。我最近发现它是一个我计划尽快用它来替换我对谷歌地图API的调用。