Google Places API - 如何将搜索限制为仅一个城市
Google Places API - How to limit the search limit to just one city
我不会将搜索范围限制在一个城市(例如"New York")
我需要有关 componentRestrictions 选项的帮助。
谢谢!
<script type="text/javascript">
function initialize() {
var options = {
types: ['address'],
componentRestrictions: {country: "us", locality: "new york"}
};
var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input, options);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
您可以通过在输入示例前添加 NY_ 来限制它,如果您想搜索华盛顿港,那么您的输入将是 NY_port_washington
我不会将搜索范围限制在一个城市(例如"New York") 我需要有关 componentRestrictions 选项的帮助。 谢谢!
<script type="text/javascript">
function initialize() {
var options = {
types: ['address'],
componentRestrictions: {country: "us", locality: "new york"}
};
var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input, options);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
您可以通过在输入示例前添加 NY_ 来限制它,如果您想搜索华盛顿港,那么您的输入将是 NY_port_washington