使用Google Map API获取Zipcode的边界和坐标。
在对沙特阿拉伯(SA)地区的地址进行地理编码时,当沙特阿拉伯的Zipcode(SA)进行地理编码时,地理编码器的结果的地址是指 2517荷兰海牙
{
"results" : [
{
"address_components" : [
{
"long_name" : "2517",
"short_name" : "2517",
"types" : [ "postal_code", "postal_code_prefix" ]
},
{
"long_name" : "The Hague",
"short_name" : "The Hague",
"types" : [ "locality", "political" ]
},
{
"long_name" : "The Hague",
"short_name" : "The Hague",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "South Holland",
"short_name" : "ZH",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Netherlands",
"short_name" : "NL",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "2517 The Hague, Netherlands",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 52.0958783,
"lng" : 4.3007563
},
"southwest" : {
"lat" : 52.0773935,
"lng" : 4.2732776
}
},
"location" : {
"lat" : 52.0847639,
"lng" : 4.2801843
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 52.0958783,
"lng" : 4.3007563
},
"southwest" : {
"lat" : 52.0773935,
"lng" : 4.2732776
}
}
},
"place_id" : "ChIJI9DHzc6wxUcR1s1th0GbWgQ",
"types" : [ "postal_code", "postal_code_prefix" ]
},
{
"address_components" : [
{
"long_name" : "2517",
"short_name" : "2517",
"types" : [ "postal_code" ]
},
{
"long_name" : "Russell Vale",
"short_name" : "Russell Vale",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Wollongong City Council",
"short_name" : "Wollongong",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "New South Wales",
"short_name" : "NSW",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Australia",
"short_name" : "AU",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Russell Vale NSW 2517, Australia",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : -34.3338503,
"lng" : 150.9245951
},
"southwest" : {
"lat" : -34.3654418,
"lng" : 150.8740632
}
},
"location" : {
"lat" : -34.3454996,
"lng" : 150.9016476
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : -34.3338503,
"lng" : 150.9245951
},
"southwest" : {
"lat" : -34.3654418,
"lng" : 150.8740632
}
}
},
"place_id" : "ChIJSaEBIk8eE2sRQIa6P2t9ARw",
"postcode_localities" : [ "Russell Vale", "Woonona" ],
"types" : [ "postal_code" ]
}
],
"status" : "OK"
}
由于结果与沙特阿拉伯无关,因此在api中添加了国家/地区限制。但它的结果有 部分结果 值真,这表示结果不准确且结果只有沙特阿拉伯位置的默认值< / p>
https://maps.googleapis.com/maps/api/geocode/json?address=2517&components=country:SA
{
"results" : [
{
"address_components" : [
{
"long_name" : "Saudi Arabia",
"short_name" : "SA",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Saudi Arabia",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 32.1542839,
"lng" : 55.6666999
},
"southwest" : {
"lat" : 16.379528,
"lng" : 34.5489978
}
},
"location" : {
"lat" : 23.885942,
"lng" : 45.079162
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 32.1542839,
"lng" : 55.6666999
},
"southwest" : {
"lat" : 16.379528,
"lng" : 34.5489978
}
}
},
"partial_match" : true,
"place_id" : "ChIJQSqV5z-z5xURm7YawktQYFk",
"types" : [ "country", "political" ]
}
],
"status" : "OK"
}
但是当使用Zipcode添加街道/地区的地址时,地理编码可以正常工作 https://maps.googleapis.com/maps/api/geocode/json?address=2517+Ar+Riyadh&components=country:SA
是否有办法迫使Gmap api对沙特阿拉伯国家的邮政编码进行地理编码,结果是准确的坐标和边界?
答案 0 :(得分:1)
看起来邮政编码对沙特阿拉伯来说并不是很好。
您可以使用component filtering搜索邮政编码,但是经常会因缺少邮政编码而获得ZERO_RESULTS。
例如,
https://maps.googleapis.com/maps/api/geocode/json?components=postal_code%3A12631%7Ccountry%3ASA
返回邮政编码,但
https://maps.googleapis.com/maps/api/geocode/json?components=postal_code%3A31433%7Ccountry%3ASA
返回ZERO_RESULTS。
对于缺少的邮政编码,您可以使用maps.google.com右下角的“发送反馈”链接。
https://support.google.com/maps/answer/162873
希望它有所帮助!