0
尝试没有地图与谷歌自动完成工作,但它是麻烦。限制谷歌自动完成的邮政编码
<script>
var autocomplete;
var countryRestrict = {country: 'NO', postalCode: '0365'}
function initAutocomplete() {
autocomplete = new google.maps.places.Autocomplete(
(document.getElementById('address-field')),
{ types: ['address'],
componentRestrictions: countryRestrict
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=API-KEY&libraries=places&callback=initAutocomplete"
async defer></script>
当我添加postalCode
到countryRestrict它停止工作,但我自己的例子中看到,他们似乎要限制其使用的例子:
componentRestrictions: {country: "AU", postalCode: "2000"}
https://developers.google.com/maps/documentation/javascript/examples/geocoding-component-restriction
是它我能够限制地址自动完成给定的邮政编码?
好吗,谢谢,我认为有可能是过滤掉任何结果(通过不显示他们),如果他们不属于该职位代码的方式,你知道的任何例子,在那里,可能会这样做? –
当您看到下拉菜单时,建议地点的详细信息(包括邮编)不可用,所以在请求详细信息之前(从下拉菜单中选择地点)之前无法过滤任何东西。 –
我正在考虑做 –