Google geocoding service returns response for fake address
geocoding, google-maps
Solution
There isn't any way for the geocoder to let you know if it thinks you had a typo. I agree with Saul's answer, that your best bet is to check your query against the response.
I just wanted to point out that you'll have to check several elements of your input against several of the response values, in order to find the elements that should match up. In this case, "Beaverton" was found inside of "DependentLocalityName".
<?xml version="1.0" encoding="UTF-8" ?>
<kml xmlns="http://earth.google.com/kml/2.0"><Response>
<name>Beverton, Ontario, Canada</name>
<Status>
<code>200</code>
<request>geocode</request>
</Status>
<Placemark id="p1">
<address>Beaverton, Brock, ON, Canada</address>
<AddressDetails Accuracy="4" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><Country><CountryNameCode>CA</CountryNameCode><CountryName>Canada</CountryName><AdministrativeArea><AdministrativeAreaName>ON</AdministrativeAreaName><SubAdministrativeArea><SubAdministrativeAreaName>Durham Regional Municipality</SubAdministrativeAreaName><Locality><LocalityName>Brock</LocalityName><DependentLocality><DependentLocalityName>Beaverton</DependentLocalityName></DependentLocality></Locality></SubAdministrativeArea></AdministrativeArea></Country></AddressDetails>
<ExtendedData>
<LatLonBox north="44.4502166" south="44.4183470" east="-79.1199562" west="-79.1839858" />
</ExtendedData>
<Point><coordinates>-79.1519710,44.4342840,0</coordinates></Point>
</Placemark>
</Response></kml>
Update:
This may be impossible to actually implement. If your input is "Beverton, Ontario, Canada", how do you know which of those three words to check for? Two of them will match up just fine. What if they're entered in a different order?
Problem
I'm using the google geocoding service to validate that a city name (plus region and country) that has been entered in our system exists, and to get the lat/long. However, I'm finding that it seems to 'guess' if you make a typo, and returns an response even if you made an error. For instance, a request for "Beverton, Ontario, Canada" returns the lat/long for Beaverton, with no indication that you provided the wrong city name. I'm using the CSV response type, and am getting the 200 response code. Can I either prevent the service from doing this, or, better yet, find out if it has? Edit: to clarify ... Google is correcting the input (when I would expect it to just fail) and I need to know if it has done this.