Google Maps API Tutorial - Did You Mean?© 2007, 2008, 2009 Mike Williams
|Translate this page:|
"Did You Mean?"The maps.google.com page will ask a "Did you mean?" question in response to an address search under certain circumstances. You might possibly want to offer the same functionality within the API.
Note: The API geocoder is quite different from the maps.google.com geocoder. Situations which cause the conditions which provoke a "Did you mean?" in one geocoder will not usually cause those conditions in the other geocoder.
Multiple HitsOne condition which provokes the question is when the geocoder returns more than one Placemark in response to the query.
To detect this situation with the API geocoder, simply test whether result.Placemark.length is greater than 1.
Here's an example
The API geocoder doesn't often return multiple results. Bispham Road, Bispham, UK is one example address which currently produces three results in the API geocoder (because there really are three Bispham Roads in Bispham).
Significantly Different AddressThe geocoder may occasionally return an address which is sufficiently different from the requested address to be worth asking the "Did you mean?" question.
For example, if you search for Bespham Road, Cleveleys, FY2, the API geocoder will return a single result for Bispham Rd, Blackpool, FY2 0, United Kingdom, which you might consider to be sufficiently different to be worth querying.
This circumstance is much harder to test for. The returned address will often look very different from the query just because the geocoder converts the address into a standard format. In this case, the fact that "Gilford" has been replaced by the zip code "03249"; and the fact that ",USA" has been added; should not be considered to be "significant" differences in the address.
I reckon that it's impractical to compare anything other than the house number and street. To go any further would require some fairly sophisticated AI to handle all the possible valid variations that might be used, and you'd almost need to write your own geocoder to check if "Gilford" actually is zip code "03249".
My strategy for matching the street is to
I've not done an awful lot of testing with this.