【问题标题】:Google Geocoder Lookup get postal code by country and cityGoogle Geocoder Lookup 按国家和城市获取邮政编码
【发布时间】:2012-09-15 04:24:10
【问题描述】:

我目前正在使用 Google Geocoder API 来确定我的网络服务的位置数据。 获取给定国家和城市的邮政编码对我来说很重要,但谷歌似乎限制了结果。

API 调用如下:

http://maps.googleapis.com/maps/api/geocode/json?address=deutschland,+saarlouis&language=de&sensor=false

结果是这样的:

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Saarlouis",
               "short_name" : "Saarlouis",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Landkreis Saarlouis",
               "short_name" : "Landkreis Saarlouis",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Saarland",
               "short_name" : "SL",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Deutschland",
               "short_name" : "DE",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Saarlouis, Deutschland",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 49.36187570,
                  "lng" : 6.815549499999999
               },
               "southwest" : {
                  "lat" : 49.26046930,
                  "lng" : 6.67501510
               }
            },
            "location" : {
               "lat" : 49.31346060,
               "lng" : 6.752286499999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 49.36187570,
                  "lng" : 6.815549499999999
               },
               "southwest" : {
                  "lat" : 49.26046930,
                  "lng" : 6.67501510
               }
            }
         },
         "types" : [ "locality", "political" ]
      }
   ],
   "status" : "OK"
}

谢谢帮助。

问候

【问题讨论】:

标签: google-maps-api-3 geocoding google-geocoder


【解决方案1】:

地理编码不提供邮政编码。 Goenames 有一个Germany 的数据库。其他国家也可以。

【讨论】:

  • 我已经查看了 geonames.org,但是免费的地址识别 API 不如 googles。检索邮政编码的方法会很有趣。
【解决方案2】:

您没有得到邮政编码的原因是查询范围太广。如果您将街道名称添加到查询中,则结果将包含邮政编码。如果您没有街道名称或不想使用街道名称,解决您的问题的方法是将地理编码分成两部分:

第 1 步:使用城市获取 GPS 坐标

https://maps.googleapis.com/maps/api/geocode/json?address=amsterdam

第 2 步:使用 GPS 坐标获取邮政编码

https://maps.googleapis.com/maps/api/geocode/json?latlng=52.3182742,4.7288558

(注意:此处发布的相同问题的两倍,由 MidnightMotion 回答。添加以使查找更容易。 https://gis.stackexchange.com/questions/33966/google-geocoder-lookup-get-postal-code-by-country-and-city)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-18
    • 2017-09-02
    • 1970-01-01
    相关资源
    最近更新 更多