【发布时间】:2026-02-27 03:20:08
【问题描述】:
我正在使用 Google 地方信息自动填充功能来查找地址,并且我希望用户能够在他们的街道地址中输入主要方向的缩写。
例如,我的用户必须完全输入“north”(例如 123 “north” willow lane),而不仅仅是“n”(例如 123 “n” willow lane)。用户大部分时间都在尝试输入“n”“s”“e”“w”,并认为我们的自动完成功能已损坏,因为自动完成功能需要完整输入的基本方向。
places API 中是否有切换此配置的设置?子串匹配?
这是我当前的代码:
我正在使用 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