我希望搜索结果仅限于地图/视口范围内。我将地图缩放到英国,然后使用地图边界搜索伦敦,但响应中也返回了美国的3个结果。如何限制搜索范围?
代码:
function codeAddress(){
geocoder = new google.maps.Geocoder();
var address = document.getElementById("inputAddress").value;
var bounds = map.getBounds();
geocoder.geocode({address: address, bounds: bounds}, function(results, status){
if(status == google.maps.GeocoderStatus.OK){
// put markers on each hit
}
});
}