2016-07-26 43 views
-1

使用Google Map API獲取Zipcode的邊界和座標。gmap api geocode zipcode沙特阿拉伯不按預期方式工作

雖然地理編碼地址爲沙特阿拉伯(SA)地區,在沙特阿拉伯的郵政編碼(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中增加了國家的限制。但它導致了部分結果,這是指結果是不準確的,它的結果只有沙特阿拉伯位置

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" 
} 

的默認值,但是,當地址的街道/地區添加了郵編地址代碼作品 https://maps.googleapis.com/maps/api/geocode/json?address=2517+Ar+Riyadh&components=country:SA

是否有辦法將Gmap api強制轉換爲地理編碼e唯一與沙特阿拉伯國家的郵政編碼和結果是準確的座標和邊界?

+1

在我看來,地理編碼器的數據庫不包括2517作爲沙特阿拉伯有效的郵政編碼。它是一個有效的郵政編碼嗎(它看起來不像我有足夠的數字)?如果是這樣,你可能需要去谷歌地圖「地圖製作」並添加它。 (請注意:您發佈的[「working example」](https://maps.googleapis.com/maps/api/geocode/json?address=2517+Ar+Riyadh&components=country:SA)返回郵政編碼55425) – geocodezip

+0

謝謝 請在下面的鏈接中找到沙特阿拉伯的郵政編碼。 http://life-in-saudiarabia.blogspot.in/2015/09/zip-codepostal-code-of-major-cities-of.html#.V5g_BvnnZBc同時使用本頁列出的任何Zipcode結果Google地理編碼不符合預期。 – Zlahc

回答

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

希望它能幫助!