views:

305

answers:

2

Hey All

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 repspond 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 ??

Any suggestions how I can get around this.

Hope you can !

+1  A: 

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.

jerebear
+1  A: 

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"
Daniel Vassallo
Wiered by removing a space works? May have to have Yahoo API backup and them maybe removing the space and trying again
Lee