用于邮政编码搜索的Google Maps API区域参数

吧台

我想使用Google Maps API来获取邮政编码的坐标。

我正在使用以下文档:https : //developers.google.com/maps/documentation/geocoding/intro?csw=1

现在,我想搜索邮政编码1200(瑞士的日内瓦)时,请使用以下URL:https : //maps.google.com/maps/api/geocode/json? region=ch&components=postal_code:1200

我得到了很多不同的结果,但是在瑞士却没有(结果在问题的结尾)。看来region参数根本不起作用,因为我在其他国家得到了结果。

当我搜索1201(也适用于日内瓦)时,它可以工作。

知道为什么吗?我宁愿没有得到任何结果,然后得到错误的结果(在其他国家/地区的结果)

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "1200",
               "short_name" : "1200",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "Region Brüssel-Hauptstadt",
               "short_name" : "Region Brüssel-Hauptstadt",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Belgien",
               "short_name" : "BE",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "1200, Belgien",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 50.86307189999999,
                  "lng" : 4.4629024
               },
               "southwest" : {
                  "lat" : 50.8337598,
                  "lng" : 4.3999935
               }
            },
            "location" : {
               "lat" : 50.850308,
               "lng" : 4.4278228
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 50.86307189999999,
                  "lng" : 4.4629024
               },
               "southwest" : {
                  "lat" : 50.8337598,
                  "lng" : 4.3999935
               }
            }
         },
         "place_id" : "ChIJNa8iqqHcw0cRG4NyYbv66KY",
         "types" : [ "postal_code" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "1200",
               "short_name" : "1200",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "Wien",
               "short_name" : "Wien",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Wien",
               "short_name" : "Wien",
               "types" : [ "postal_town" ]
            },
            {
               "long_name" : "Wien",
               "short_name" : "Wien",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Österreich",
               "short_name" : "AT",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "1200 Wien, Österreich",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 48.2646423,
                  "lng" : 16.4007913
               },
               "southwest" : {
                  "lat" : 48.2252299,
                  "lng" : 16.3618448
               }
            },
            "location" : {
               "lat" : 48.235668,
               "lng" : 16.373098
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 48.2646423,
                  "lng" : 16.4007913
               },
               "southwest" : {
                  "lat" : 48.2252299,
                  "lng" : 16.3618448
               }
            }
         },
         "place_id" : "ChIJs0PDoUQGbUcRI9VvmpZbVzQ",
         "types" : [ "postal_code" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "1200",
               "short_name" : "1200",
               "types" : [ "postal_code", "postal_code_prefix" ]
            },
            {
               "long_name" : "Lissabon",
               "short_name" : "Lissabon",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Lissabon",
               "short_name" : "Lissabon",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Portugal",
               "short_name" : "PT",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "1200 Lissabon, Portugal",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 38.7177413,
                  "lng" : -9.1387655
               },
               "southwest" : {
                  "lat" : 38.7006072,
                  "lng" : -9.168078299999999
               }
            },
            "location" : {
               "lat" : 38.7096083,
               "lng" : -9.1539178
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 38.7177413,
                  "lng" : -9.1387655
               },
               "southwest" : {
                  "lat" : 38.7006072,
                  "lng" : -9.168078299999999
               }
            }
         },
         "place_id" : "ChIJT3JAUYI0GQ0R4Nc7DsHrABw",
         "types" : [ "postal_code", "postal_code_prefix" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "1200",
               "short_name" : "1200",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "Mbombela",
               "short_name" : "Mbombela",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Mbombela",
               "short_name" : "Mbombela",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Ehlanzeni",
               "short_name" : "Ehlanzeni",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Mpumalanga",
               "short_name" : "MP",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Südafrika",
               "short_name" : "ZA",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Mbombela, 1200, Südafrika",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : -25.434559,
                  "lng" : 31.035606
               },
               "southwest" : {
                  "lat" : -25.5273621,
                  "lng" : 30.9615131
               }
            },
            "location" : {
               "lat" : -25.4922163,
               "lng" : 31.0048384
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : -25.434559,
                  "lng" : 31.035606
               },
               "southwest" : {
                  "lat" : -25.5273621,
                  "lng" : 30.9615131
               }
            }
         },
         "place_id" : "ChIJC-Upoo1J6B4RbhfORqGdY2s",
         "types" : [ "postal_code" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "1200",
               "short_name" : "1200",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "København K",
               "short_name" : "København K",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "København",
               "short_name" : "København",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Dänemark",
               "short_name" : "DK",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "1200 København K, Dänemark",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 55.6788537,
                  "lng" : 12.581048
               },
               "southwest" : {
                  "lat" : 55.6774083,
                  "lng" : 12.5790574
               }
            },
            "location" : {
               "lat" : 55.6780957,
               "lng" : 12.5799054
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 55.6794799802915,
                  "lng" : 12.5814016802915
               },
               "southwest" : {
                  "lat" : 55.6767820197085,
                  "lng" : 12.5787037197085
               }
            }
         },
         "place_id" : "ChIJuYvG1hZTUkYREL3-tlYomQk",
         "types" : [ "postal_code" ]
      }
   ],
   "status" : "OK"
}
自己的

就像邓肯说的那样,区域代码只会影响而不完全限制地理编码器的结果。要了解更多信息,请检查区域偏向

如果要在某个国家/地区获得特定结果,请使用component = country而不是地区。

我试图在瑞士国家/地区请求postal_code:1200我得到零结果。因此,请确保您正在使用的请求是有效的。

https://maps.google.com/maps/api/geocode/json?components=postal_code:1200|country:CH

而且,如果我尝试了postal_code:1201,那么我会得到您想要的特定结果。

https://maps.google.com/maps/api/geocode/json?components=postal_code:1201|country:CH

如果您确定postal_code:1200在瑞士是有效的邮政编码,那么Google Maps可能不认为postal_code是瑞士日内瓦的邮政编码。

尝试也检查一下我回答的这个相关的SO问题

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用Google Maps API将邮政编码转换为纬度/经度坐标吗?

来自分类Dev

地址对象中带有PHP的Google API JSON邮政编码

来自分类Dev

Bing的Geolocation Maps API-墨西哥的邮政编码

来自分类Dev

使用Javascript API的多个邮政编码根据带有标记的Google Map位置

来自分类Dev

Google Maps API-地理编码和附近搜索

来自分类Dev

如何使用带有PHP的Google Maps API将邮政编码转换为经/纬度?

来自分类Dev

搜索邮政编码范围并拉出相应的区域

来自分类Dev

如何使用Google Maps API从邮政编码获取状态(德国)?

来自分类Dev

如何从Google Map的自动填充API获取邮政编码

来自分类Dev

用于邮政编码搜索的Google Maps API区域参数

来自分类Dev

ROR API尝试创建邮政编码搜索

来自分类Dev

Google Maps不会使用Google Data Studio填充Google表格中的所有邮政编码

来自分类Dev

将Google Maps设置为在加载时对邮政编码进行地理编码

来自分类Dev

如何使用Maps API v2自动显示当前位置的街道名称,邮政编码/邮政编码,城市

来自分类Dev

在Google Maps中将邮政编码转换为latlng时出现Javascript错误

来自分类Dev

Bing的Geolocation Maps API-墨西哥的邮政编码

来自分类Dev

使用Google api v3输入邮政编码时的搜索位置

来自分类Dev

使用Google Maps Api的邮政编码边界

来自分类Dev

使用Javascript API的多个邮政编码根据标记提供的Google Maps位置

来自分类Dev

Google Maps API-地理编码和附近搜索

来自分类Dev

在Google Maps API中显示区域

来自分类Dev

将Google Maps地址查找限制为特定的邮政编码

来自分类Dev

使用Google Maps API从用户的邮政编码中查找最近的条

来自分类Dev

如何使用Google Maps API从邮政编码获取状态(德国)?

来自分类Dev

Google Maps API-仅按邮政编码检索

来自分类Dev

Google Maps API参数

来自分类Dev

Google Maps Places API-如何在多个结果上使用Google Maps搜索框获取国家/地区,邮政编码,数字,网站URL

来自分类Dev

谷歌地图 API 搜索特定国家的邮政编码

来自分类Dev

覆盖整个区域的最佳方式通过邮政编码进行搜索

Related 相关文章

  1. 1

    使用Google Maps API将邮政编码转换为纬度/经度坐标吗?

  2. 2

    地址对象中带有PHP的Google API JSON邮政编码

  3. 3

    Bing的Geolocation Maps API-墨西哥的邮政编码

  4. 4

    使用Javascript API的多个邮政编码根据带有标记的Google Map位置

  5. 5

    Google Maps API-地理编码和附近搜索

  6. 6

    如何使用带有PHP的Google Maps API将邮政编码转换为经/纬度?

  7. 7

    搜索邮政编码范围并拉出相应的区域

  8. 8

    如何使用Google Maps API从邮政编码获取状态(德国)?

  9. 9

    如何从Google Map的自动填充API获取邮政编码

  10. 10

    用于邮政编码搜索的Google Maps API区域参数

  11. 11

    ROR API尝试创建邮政编码搜索

  12. 12

    Google Maps不会使用Google Data Studio填充Google表格中的所有邮政编码

  13. 13

    将Google Maps设置为在加载时对邮政编码进行地理编码

  14. 14

    如何使用Maps API v2自动显示当前位置的街道名称,邮政编码/邮政编码,城市

  15. 15

    在Google Maps中将邮政编码转换为latlng时出现Javascript错误

  16. 16

    Bing的Geolocation Maps API-墨西哥的邮政编码

  17. 17

    使用Google api v3输入邮政编码时的搜索位置

  18. 18

    使用Google Maps Api的邮政编码边界

  19. 19

    使用Javascript API的多个邮政编码根据标记提供的Google Maps位置

  20. 20

    Google Maps API-地理编码和附近搜索

  21. 21

    在Google Maps API中显示区域

  22. 22

    将Google Maps地址查找限制为特定的邮政编码

  23. 23

    使用Google Maps API从用户的邮政编码中查找最近的条

  24. 24

    如何使用Google Maps API从邮政编码获取状态(德国)?

  25. 25

    Google Maps API-仅按邮政编码检索

  26. 26

    Google Maps API参数

  27. 27

    Google Maps Places API-如何在多个结果上使用Google Maps搜索框获取国家/地区,邮政编码,数字,网站URL

  28. 28

    谷歌地图 API 搜索特定国家的邮政编码

  29. 29

    覆盖整个区域的最佳方式通过邮政编码进行搜索

热门标签

归档