簡體   English   中英

Google API自動完成限制

[英]Google API autocomplete restrictions

是否可以將自動填充功能限制在一個國家/地區內?

這是我目前所擁有的

var input = document.getElementById('autocomplete');
var options = {
    type: ['locality'],
    componentRestrictions: {country: 'au'}
};
new google.maps.places.Autocomplete(input, options);

您無法使用Google Maps API限制區域,但是可以設置本質上可以解決問題的邊界。

界限及其使用方法的簡介: http : //code.google.com/apis/maps/documentation/javascript/reference.html#LatLngBounds https://aiocollective.com/blog/getbounds-in-google-maps -API-V3 /

您可以根據縣限制自動填充結果。 在這里您可以看到google官方示例。如果您需要更多幫助,請寫評論或更新您的問題。

而“安斯之上”也很完美,因此您也可以使用它。

將自動完成功能放置在多個國家/地區

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM