当用户开始输入城市时,autosuggest仅建议距离坦帕,佛罗里达州(或其他任何地方)50英里范围内的城市
var southWest = new google.maps.LatLng( 28.3914,-81.936035 );
var northEast = new google.maps.LatLng( 28.3914,-81.936035 );
var hyderabadBounds = new google.maps.LatLngBounds( southWest, northEast );
var options = {
bounds: hyderabadBounds,
types: ['geocode'],
componentRestrictions: { country: 'us' }
};
var input1 = document.getElementById('search_header');
var autocomplete = new google.maps.places.Autocomplete(input1,options);
答案 0 :(得分:1)
您使用相同的LatLng用于NorthEast和SouthWest的hyderabadBounds,使用包含所需区域的LatLngBounds对象,例如:
bounds: new google.maps.Circle({center:new google.maps.LatLng( 28.3914,-81.936035 ),
radius:50000}).getBounds()
注意:无法保证自动完成将结果限制为给定范围