获取给定邮政编码和/或地址字符串的纬度和经度



这个旧的API语法:

https://maps.googleapis.com/maps/api/geocode/json?address=L12+3TS%2c%2bUK&传感器=错误&客户端=XYZ&签名=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/"
  }
}

这是足够公平的。我研究过这个,但找不到新的语法。有人能帮我吗?理想情况下,我还希望能够获得给定英国地址字符串的纬度和经度。谢谢

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

所以问题可能出在你的客户端参数上。

相关内容

  • 没有找到相关文章

最新更新