I'm using Geocoder for my app and it works just fine, except one thing - it ALWAYS return results even for non-existing address and always the same results. So if i'm sending some "asfasdfsdgsdg" - it gets me a results somewhere in KANSAS and i need no results instead.
this.geocoder.geocode(geocoderRequestParams, (results, status) => {
if ((status === 'OK') && results && results[0]) {
this.searchStoresByCoordinates(
{
//These are always the same for random search phrase like "dsafsdagasgasgasg"
latitude: results[0].geometry.location.lat(),
longitude: results[0].geometry.location.lng()
},
//This one becomes United States
results[0].formatted_address
);
} else {
//Need to be here
}
});
Request params:
const geocoderRequestParams = {
address: "sdfdgdfhdfhsdh",
componentRestrictions: {
country: "US"
}
};
Got it. Just added handling for
results[0].formatted_address !== 'United States'