Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.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 Google Places API自动完成上的偏差位置返回_Javascript_Jquery_Google Places Api - Fatal编程技术网

Javascript Google Places API自动完成上的偏差位置返回

Javascript Google Places API自动完成上的偏差位置返回,javascript,jquery,google-places-api,Javascript,Jquery,Google Places Api,我正在使用GooglePlacesAPI自动完成街道地址搜索。我希望将结果偏移到特定经度和纬度周围50英里的半径(这是一个固定位置,不取决于用户)。目前,它会自动完成地址,但不会基于位置对地址进行偏移(美国境内的情况除外)。具体地说,我想在纬度34.159947,经度118.257017周围偏移300英里半径 <script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places">

我正在使用GooglePlacesAPI自动完成街道地址搜索。我希望将结果偏移到特定经度和纬度周围50英里的半径(这是一个固定位置,不取决于用户)。目前,它会自动完成地址,但不会基于位置对地址进行偏移(美国境内的情况除外)。具体地说,我想在纬度34.159947,经度118.257017周围偏移300英里半径

<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
        ...
<input id="address-search" type="text" value="" name="subject">


$(document).ready(function() {
    var input = document.getElementById('address-input');
    var options = {componentRestrictions: {country: 'us'} };               
    new google.maps.places.Autocomplete(input, options); 
    google.maps.event.addDomListener(window, 'load', initialize);
});

...
$(文档).ready(函数(){
var input=document.getElementById('address-input');
var options={componentRestrictions:{country:'us'}};
新的google.maps.places.Autocomplete(输入,选项);
google.maps.event.addDomListener(窗口“加载”,初始化);
});

不能给它一个半径,但可以给它一个矩形边界

var defaultBounds = new google.maps.LatLngBounds(
  new google.maps.LatLng(-33.8902, 151.1759),
  new google.maps.LatLng(-33.8474, 151.2631)
);

var options = {bounds: defaultBounds };  

请参阅

谢谢。顺便说一句,第4行有一个额外的括号