Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Google API 自动完成功能。我试图只限制澳大利亚。但它建议国家的每个城市。例如,如果我输入“新”,它也建议纽约。我不想那样。我只想显示澳大利亚的城市
工作示例在Jsfiddle中。提前致谢
也许回答太晚了......但是,这对我有用:将以下内容放入您的initialize()方法中
initialize()
var input = document.getElementById('searchTextField'); var options = { types: ['(cities)'], componentRestrictions: {country: 'au'} }; var autocomplete = new google.maps.places.Autocomplete(input, options);