首页 文章

Google Geocoder Lookup按国家/地区和城市获取邮政编码

提问于
浏览
2

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

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

谢谢你的帮助 .

问候

2 回答

  • 0

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

  • 0

    你没有得到邮政编码的原因是查询过于宽泛 . 如果要在查询中添加街道名称,结果将包含邮政编码 . 如果您没有街道名称或不想使用街道名称解决问题,请将地理编码分为两部分:

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

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

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

    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

相关问题