Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps 限制谷歌地图搜索在城市边界内自动完成的位置?_Google Maps - Fatal编程技术网

Google maps 限制谷歌地图搜索在城市边界内自动完成的位置?

Google maps 限制谷歌地图搜索在城市边界内自动完成的位置?,google-maps,Google Maps,如何限制google place在一个城市内的搜索边界,以及机构 我希望用户能够搜索特定区域内的机构-城市 var options = { componentRestrictions: { country: 'PH'} }; var autocomplete = new google.maps.places.Autocomplete(input, options);

如何限制google place在一个城市内的搜索边界,以及机构

我希望用户能够搜索特定区域内的机构-城市

var options = {
                componentRestrictions: {
                    country: 'PH'}
            };
            var autocomplete = new google.maps.places.Autocomplete(input, options);
            autocomplete.bindTo('bounds', map);
在网页上创建文本输入字段,提供UI拾取列表中位置的预测,并返回位置详细信息以响应getPlace()请求

cities
)类型集合指示Places服务返回与
locality
administrative\u area3
匹配的结果

使用
componentRestrictions
选项将自动完成搜索限制在特定国家/地区。以下代码将结果限制在法国境内的城市

var input = document.getElementById('searchTextField');
var options = {
types: ['(cities)'],
componentRestrictions: {country: 'fr'}
};

autocomplete = new google.maps.places.Autocomplete(input, options);
有关如何限制搜索的详细信息,请查看本教程页面: