【问题标题】:Google Places Autocomplete API - Abbreviate Cardinal Direction on inputGoogle Places Autocomplete API - 输入时的缩写基本方向
【发布时间】:2026-02-27 03:20:08
【问题描述】:

我正在使用 Google 地方信息自动填充功能来查找地址,并且我希望用户能够在他们的街道地址中输入主要方向的缩写。

例如,我的用户必须完全输入“north”(例如 123 “north” willow lane),而不仅仅是“n”(例如 123 “n” willow lane)。用户大部分时间都在尝试输入“n”“s”“e”“w”,并认为我们的自动完成功能已损坏,因为自动完成功能需要完整输入的基本方向。

places API 中是否有切换此配置的设置?子串匹配?

https://developers.google.com/maps/documentation/places/web-service/autocomplete#PlaceAutocompleteMatchedSubstring


这是我当前的代码:

我正在使用 Javascript。

导入自动完成:

  async mounted() {
    const maps = await this.$GMaps()
    this.autocompleteService = new maps.places.AutocompleteService()
  },

使用自动完成获得预测:

this.autocompleteService.getPlacePredictions({ input: searchAddress }, (predictions) => {
        this.addressPredictions = predictions
      })

(我正在使用 Nuxt / Vue)

【问题讨论】:

    标签: javascript google-maps-api-3 autocomplete google-places-api googleplacesautocomplete


    【解决方案1】:

    这与谷歌自动完成无关。 Console.logging 显示返回的结果带有缩写的基本方向。

    相反,这是 Vuetify 的 v-autocomplete 过滤掉所需建议的问题。 V-autocomplete 可以配置 "no-filter" 属性来显示这些结果

    【讨论】:

      最近更新 更多