Google geocoding returns response for fake address

I use the google geocoding service to verify that the city name (plus region and country) that was entered in our system also exists to receive lat / long.

However, I found that it seems to be "guessing" if you make a typo, and returns an answer, even if you made a mistake.

For example, the query "Beverton, Ontario, Canada" returns lat / long for Beaverton without indicating that you entered the wrong city name.

I use the CSV response type and get a 200 response code.

Can I either prevent the service from doing this, or, even better, find out if it has one?

Edit: clarify ... Google corrects the input (when I expect it to just work), and I need to know if it did this.

+6
google-maps geocoding
source share
3 answers

The geocoder cannot tell you if you have a typo. I agree with Saul's answer that it is best to check your request for a response.

I just wanted to point out that you would need to check multiple elements of your input for multiple response values ​​to find elements that should match. In this case, "Beaverton" was found inside the "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 not be possible to implement. If your entry is Beverton, Ontario, Canada, how do you know which of the three words to check? Two of them will fit well. What if they are entered in a different order?

+3
source share

Does it answer "Success Code 200"? There is a chance that he can give you a different status code.

Following are the google status codes: http://code.google.com/apis/maps/documentation/reference.html#GGeoStatusCode

0
source share

NOTE. See answer from @Chris B above. As Chris points out, this may not be possible to implement.

Do you need to use CSV response type? If not, other types of responses, such as KML, provide enough details to determine the location referenced by the coordinates. You can confirm your entry against the LocalityName element of the response.

 <kml xmlns="http://earth.google.com/kml/2.0"> <Response> <name>1600 amphitheatre mountain view ca</name> <Status> <code>200</code> <request>geocode</request> </Status> <Placemark> <address> 1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA </address> <AddressDetails Accuracy="8"> <Country> <CountryNameCode>US</CountryNameCode> <AdministrativeArea> <AdministrativeAreaName>CA</AdministrativeAreaName> <SubAdministrativeArea> <SubAdministrativeAreaName>Santa Clara</SubAdministrativeAreaName> <Locality> <LocalityName>Mountain View</LocalityName> <Thoroughfare> <ThoroughfareName>1600 Amphitheatre Pkwy</ThoroughfareName> </Thoroughfare> <PostalCode> <PostalCodeNumber>94043</PostalCodeNumber> </PostalCode> </Locality> </SubAdministrativeArea> </AdministrativeArea> </Country> </AddressDetails> <Point> <coordinates>-122.083739,37.423021,0</coordinates> </Point> </Placemark> </Response> </kml> 
0
source share

All Articles