I am trying to restrict the returned addresses from Google Maps geocoder API like so:
var geocoder = new google.maps.Geocoder();
var auVicSwLatLon = new google.maps.LatLng(-39.234713, 140.962526);
var auVicNeLatLon = new google.maps.LatLng(-33.981125, 149.975296);
var auVicLatLonBounds = new google.maps.LatLngBounds(auVicSwLatLon, auVicNeLatLon);
geocoder.geocode(
{
address: searchStr,
region: 'AU',
// bounds: auVicLatLonBounds,
},
function(results, status) {
// ... do stuff here
}
);
Restriction using region works. However restriction using bounds does no - when I uncomment the bounds attribute above, I get no results. Leave it commented, I get results from all over Australia.
Is there something I have done wrong here?
Thanks!
Additional info:
Relevant documentation here:
https://developers.google.com/maps/documentation/javascript/geocoding
and here:
https://developers.google.com/maps/documentation/javascript/reference#Geocoder
Note that the values I have used in LatLngBounds
are for that of the state of Victoria (VIC). That is really what I am trying to achieve here. Thus if you know of an alternative way to accomplish this, please also answer this question!
bounds
without theregion
? Perhaps they cannot be used together. – Andrew Leach