是否可以将自动完成搜索仅限于城市和邮政编码?
这行不通:
autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
{types: ['(cities', '(postal_code)'], componentRestrictions: {country: "de"}});
也许这是对的吗?
autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
{types: ['(regions)'], componentRestrictions: {country: "de"}});
来源:https://developers.google.com/places/supported_types
但是自动填充功能也会在我的受限国家/地区以外显示一些结果,为什么?
一些建议?
解决方案
autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
{types: ['(regions)'], componentRestrictions: {'country': "de"}});
答案 0 :(得分:0)
下面的代码是我问题的正确答案。
autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
{types: ['(regions)'], componentRestrictions: {'country': "de"}});