Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 570
Lee Avatar asked Jan 25 '10 20:01

Lee


People also ask

What does geocode return?

The geocoder does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language.

Is Google Maps geocoding API free?

The Geocoding API uses a pay-as-you-go pricing model. Geocoding API requests generate calls to one of two SKUs depending on the type of request: basic or advanced.

Is there any free geocoding API?

While most geocoding services come with a hefty price tag or credit fee, QGIS offers several geocoding plugins for free. And the best part about QGIS is that it's completely open-source licensed under the GNU General Public License. In QGIS 3, geocoding is all in open source using the OSM Place Search plugin.


2 Answers

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"
like image 66
Daniel Vassallo Avatar answered Nov 12 '22 13:11

Daniel Vassallo


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.

like image 32
jerebear Avatar answered Nov 12 '22 11:11

jerebear