admin管理员组文章数量:1417070
Trying to work with the Google Autoplete without maps, but it's being troublesome.
<script>
var autoplete;
var countryRestrict = {country: 'NO', postalCode: '0365'}
function initAutoplete() {
autoplete = new google.maps.places.Autoplete(
(document.getElementById('address-field')),
{ types: ['address'],
ponentRestrictions: countryRestrict
});
}
</script>
<script src=";libraries=places&callback=initAutoplete"
async defer></script>
when I add postalCode
to countryRestrict it stops working, yet I see in their own example that they seem to be restricting it by using the example:
ponentRestrictions: {country: "AU", postalCode: "2000"}
Is it possible for me to limit the address autoplete to a given postal code?
Trying to work with the Google Autoplete without maps, but it's being troublesome.
<script>
var autoplete;
var countryRestrict = {country: 'NO', postalCode: '0365'}
function initAutoplete() {
autoplete = new google.maps.places.Autoplete(
(document.getElementById('address-field')),
{ types: ['address'],
ponentRestrictions: countryRestrict
});
}
</script>
<script src="https://maps.googleapis./maps/api/js?key=API-KEY&libraries=places&callback=initAutoplete"
async defer></script>
when I add postalCode
to countryRestrict it stops working, yet I see in their own example that they seem to be restricting it by using the example:
ponentRestrictions: {country: "AU", postalCode: "2000"}
https://developers.google./maps/documentation/javascript/examples/geocoding-ponent-restriction
Is it possible for me to limit the address autoplete to a given postal code?
Share Improve this question edited Mar 7, 2016 at 15:02 geocodezip 161k14 gold badges227 silver badges255 bronze badges asked Mar 7, 2016 at 10:55 Sebastian Jennings AlmnesSebastian Jennings Almnes 1,6082 gold badges20 silver badges33 bronze badges1 Answer
Reset to default 4Currently it's not possible, the only supported ponentRestriction for an Autoplete is country
(The linked example is an implementation of geocoding, where more ponentRestrictions are supported )
Adding other ponentRestrictions than the supported options results in a script-error which breaks the Autoplete
本文标签: javascriptLimit google autocomplete to a postal codeStack Overflow
版权声明:本文标题:javascript - Limit google autocomplete to a postal code - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745260458a2650333.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论