2014-10-08 79 views
0

這舊的API語法:獲得緯度和經度給出郵政編碼和/或地址字符串

https://maps.googleapis.com/maps/api/geocode/json?address=L12+3TS%2c%2bUK&sensor=false&client=XYZ&signature=XYZ

應該返回給英國郵政編碼的經度和緯度。它返回:

{ 
    "Status": { 
    "code": 620, 
    "request": "geocode", 
    "error_message": "The Geocoding API v2 has been turned down on September 9th, 2013. The Geocoding API v3 should be used now. Learn more at https://developers.google.com/maps/documentation/geocoding/" 
    } 
} 

這是公平的。我研究了this,但找不到新的語法。有人可以幫我嗎?理想情況下,我還希望能夠獲得給定英國地址字符串的經度和緯度。謝謝。

回答

0
https://maps.googleapis.com/maps/api/geocode/json?address=L12+3TS%2c%2bUK&sensor=false 

爲我工作(我刪除客戶端&簽名信息),給出以下結果:

{ 
    "results" : [ 
     { 
     "address_components" : [ 
      { 
       "long_name" : "L12", 
       "short_name" : "L12", 
       "types" : [ "postal_code_prefix", "postal_code" ] 
      }, 
      { 
       "long_name" : "Liverpool", 
       "short_name" : "Liverpool", 
       "types" : [ "postal_town" ] 
      }, 
      { 
       "long_name" : "Merseyside", 
       "short_name" : "Mersyd", 
       "types" : [ "administrative_area_level_2", "political" ] 
      }, 
      { 
       "long_name" : "Royaume-Uni", 
       "short_name" : "GB", 
       "types" : [ "country", "political" ] 
      } 
     ], 
     "formatted_address" : "Liverpool, Merseyside L12, Royaume-Uni", 
     "geometry" : { 
      "bounds" : { 
       "northeast" : { 
        "lat" : 53.4605852, 
        "lng" : -2.8675854 
       }, 
       "southwest" : { 
        "lat" : 53.4183146, 
        "lng" : -2.9233403 
       } 
      }, 
      "location" : { 
       "lat" : 53.43679479999999, 
       "lng" : -2.8881009 
      }, 
      "location_type" : "APPROXIMATE", 
      "viewport" : { 
       "northeast" : { 
        "lat" : 53.4605852, 
        "lng" : -2.8675854 
       }, 
       "southwest" : { 
        "lat" : 53.4183146, 
        "lng" : -2.9233403 
       } 
      } 
     }, 
     "partial_match" : true, 
     "types" : [ "postal_code_prefix", "postal_code" ] 
     } 
    ], 
    "status" : "OK" 
} 

那麼問題可能是在你的客戶端參數。

+0

謝謝。你還可以得到這個地址/郵政編碼的中心嗎? – cs0815 2014-10-08 15:22:43