troubleshooting Question

Why Google API returns different results than Google Maps?

Avatar of gplana
gplanaFlag for Spain asked on
PHPGIS/GPS Programming
11 Comments1 Solution2134 ViewsLast Modified:
Hi.

I have this function in php which uses Google API to convert an address to its GPS coordinates:

   $googleKey = 'my google key here';
   function gps_coordinates($address) {
      global $googleKey;
      $url = 'http://maps.google.com/maps/geo?q='. urlencode($address) . '&output=json&oe=utf8&sensor=false&key='.$googleKey;
//echo "$url <br />\n";
      $content = file_get_contents($url);
//echo htmlentities($content)."<br />\n";
      $json = json_decode($content);
      return $json->Placemark[0]->Point->coordinates;
   }

It works ok, but for some addres I'm getting innacurate coordinates. For example, if I call this function with address "calle don jaime I, 26 50001 zaragoza  Spain" this function returns coordinates 41.6524051,-0.879501 instead of 41.692248,1.745868 which are the coordinates returned by google map: https://maps.google.es/maps?q=calle+don+jaime+I,+26+%0950001+%09zaragoza+%09Spain&hl=es&sll=41.692248,1.745868&sspn=3.359188,4.938354&hnear=Calle+Don+Jaime+I,+26,+50003+Zaragoza&t=m&z=17

Why?

Thanks.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros