Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.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
Javascript 如何仅获取特定城市的所有局部区域_Javascript_Google Maps_Google Maps Api 3_Google Places Api - Fatal编程技术网

Javascript 如何仅获取特定城市的所有局部区域

Javascript 如何仅获取特定城市的所有局部区域,javascript,google-maps,google-maps-api-3,google-places-api,Javascript,Google Maps,Google Maps Api 3,Google Places Api,我有一个文本框来输入城市的局部区域(在后端),只有定义的城市的特定区域应该在GoogleAPI自动完成中出现 我试过代码,但它也向其他城市和本地区显示 以下是我尝试过的代码: function initialize() { var latcity = $("#latcity ").val(); var longcity = $("#longcity").val(); var defaultBounds = new google.maps.LatLngBounds( new google.map

我有一个文本框来输入城市的局部区域(在后端),只有定义的城市的特定区域应该在GoogleAPI自动完成中出现

我试过代码,但它也向其他城市和本地区显示

以下是我尝试过的代码:

function initialize() {

var latcity = $("#latcity ").val();
var longcity = $("#longcity").val();
var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(latcity ,longcity ),
new google.maps.LatLng(latcity ,longcity ));
var input = document.getElementById('enteredaddress');
var options = {
  bounds: defaultBounds,
  types: ['establishment']
};
autocomplete = new google.maps.places.Autocomplete(input, options);

autocomplete.addListener('place_changed', function () {
    var address = $("#pick-addrs").val();
    var place = autocomplete.getPlace();
    if (!place.geometry) {
        return;
    }
});
}

google.maps.event.addDomListener(window, 'load', initialize);
HTML:

<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<input type='text' name='localaddress' id="localaddress">
<input type='hidden' name='latcity' id="latcity" value="LATVALUE">
<input type='hidden' name='longcity' id="longcity" value="LONGVALUE">


我在使用城市的经纬度

你找到解决方案了吗?