【问题标题】:Google maps city search谷歌地图城市搜索
【发布时间】:2019-03-04 01:35:41
【问题描述】:

我们有一个使用 google maps api 自动填写城市详细信息字段的自动完成字段

因此,使用“(城市)”作为类型,我们会得到一个与搜索结果匹配的城市列表,但是数据并不一致,而且澳大利亚的大城市缺少诸如邮政编码字段之类的内容。如下查找

 this.autocomplete = new google.maps.places.Autocomplete((this.element), { types: ["(cities)"] , componentRestrictions: {country: ["au","nz"]}});

因此,当搜索诸如“里士满”之类的郊区之类的城市时,您会得到以下响应

/**/_xdc_._n1gyyx && _xdc_._n1gyyx( {
   "html_attributions" : [],
   "result" : {
      "address_components" : [
         {
            "long_name" : "Richmond",
            "short_name" : "Richmond",
            "types" : [ "locality", "political" ]
         },
         {
            "long_name" : "Yarra City",
            "short_name" : "Yarra",
            "types" : [ "administrative_area_level_2", "political" ]
         },
         {
            "long_name" : "Victoria",
            "short_name" : "VIC",
            "types" : [ "administrative_area_level_1", "political" ]
         },
         {
            "long_name" : "Australia",
            "short_name" : "AU",
            "types" : [ "country", "political" ]
         },
         {
            "long_name" : "3121",
            "short_name" : "3121",
            "types" : [ "postal_code" ]
         }
      ],

带有“postal_code”和“locality”、“political”

但是在墨尔本搜索你会期望邮政编码 3000 的详细信息,但你只会得到

/**/_xdc_._ntt86i && _xdc_._ntt86i( {
   "html_attributions" : [],
   "result" : {
      "address_components" : [
         {
            "long_name" : "Melbourne",
            "short_name" : "Melbourne",
            "types" : [ "colloquial_area", "locality", "political" ]
         },
         {
            "long_name" : "Victoria",
            "short_name" : "VIC",
            "types" : [ "administrative_area_level_1", "political" ]
         },
         {
            "long_name" : "Australia",
            "short_name" : "AU",
            "types" : [ "country", "political" ]
         }
      ],

所以现在名称存储在“colloquial_area”、“locality”、“political”中,并且没有“postal_code”

但是,在自动完成功能中过滤墨尔本时,您得到的只是墨尔本选项或墨尔本机场,两者都不正确。如果您随后将类型更改为“(地区),您可以搜索返回正确墨尔本版本的邮政编码。

有没有人遇到过这种情况并想出了一种方法来强制过滤结果只显示带有邮政编码的版本?

【问题讨论】:

  • 大城市没有唯一的邮政编码

标签: google-maps


【解决方案1】:

此行为按预期工作,因为像墨尔本这样的地方在其区域内有多个邮政编码(例如 3977、3156、3806、3978 等),因此,结果不会返回邮政编码,因为它不是用来处理的多个邮政编码,并且不能返回单个邮政编码,因为这会影响信息的完整性,因为它不适用于其余的邮政编码。

您可以在Issue Tracker 中提出功能请求,以请求这种处理多个邮政编码的能力。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-21
    • 2010-11-09
    • 1970-01-01
    • 2017-10-25
    相关资源
    最近更新 更多