Lee
Lee

Reputation: 20914

Google Map GEO Results

I'm getting really frustrated with Google geo results and hope someone can advise me the best was to go.

I have created a AutoSuggest feature where you can start typing the address and Google will respond with suggestions. User then selects and address to move on.

But before I want them to continue on the next page I want to validate their selection. I would have thought this will be easy as we are only checking against what Google has already given. But when I do my validation lookup it displays no results.

Some example code:

Lets say I picked from the suggestion this address: Suffield, CT 06078, USA

Then on validation I do a second lookup with this address ie.

$string = "Suffield, CT 06078, USA";    
echo 'http://maps.google.com/maps/geo?output=json&oe=utf8&gl=us&sensor=false&key=[MyKey]&q='.urlencode($string).'';

It gives me Error code 602 (G_GEO_UNKNOWN_ADDRESS)

How can it not be found when its given me the address?

How I can get around this?

Upvotes: 7

Views: 2844

Answers (2)

jerebear
jerebear

Reputation: 6655

It's really strange, to be sure, but I was able to validate the address using the full state name.

Doesn't work:

http://maps.google.com/maps/geo?output=json&oe=utf8&gl=us&sensor=false&key=[MyKey]&q=Suffield,%20CT%2006078

Does Work:

http://maps.google.com/maps/geo?output=json&oe=utf8&gl=us&sensor=false&key=[MyKey]&q=Suffield,%20Connecticut%2006078

And yes, the address they provided to you doesn't work in their own system. That being said, searching for Hartford, CT DOES work. It appears there may be a listing discrepency in their data whereby Suffield + CT returns false results.

Upvotes: 1

Daniel Vassallo
Daniel Vassallo

Reputation: 344291

You're right. That is quite strange.

Note that it does work when you remove the space between CT and 06078:

http://maps.google.com/maps/geo?q=Suffield,+CT06078,+USA&output=csv&sensor=false

The above returns 41.9817631,-72.6506462. (Link to Google Maps)


Reverse geocoding those coordinates with:

http://maps.google.com/maps/geo?q=41.9817631,-72.6506462&output=csv&sensor=false

returns:

200,4,"Suffield, CT, USA"

Upvotes: 3

Related Questions