I'm using the google geocoder with an option to only return results from Germany
Here's the relevant part of my function
...
var geocoder = new google.maps.Geocoder();
geocoder.geocode({"address":address,"region":"DE" }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0].geometry.location) {
completeGeo(results[0],address);
} else {
completeGeo(null,address);
}
...
but if i geocode "cuvry" too find that street in germany
google returns for example "Cuvry, France" which is outside of the region parameter
How can I prevent google geocoder from returning results that are not in a certain Country? I mean return, not check in callback if country-code is matching.
This might work using component filters. "components":"country:DE"
var geocoder = new google.maps.Geocoder();
geocoder.geocode({"address":address, "componentRestrictions":{"country":"DE"} },
function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0].geometry.location) {
completeGeo(results[0],address);
} else {
completeGeo(null,address);
}
});