4

I'm using the Google Geocoding API to get the lat/lng co-ordinates for different location searches on my site. The problem is that for areas of London (it might not be restricted to just London that's just where most of our user base is) such as "Waterloo" the geocoding api is returning different results to my server from when i put the url directly in my browser. This is the url that is generated for waterloo:

http://maps.googleapis.com/maps/api/geocode/xml?address=waterloo,%20london,%20england&bounds=48.8,-11.2|60.9,1.9&sensor=false&region=uk

If i paste this into my browser I get the correct area of Waterloo ("Waterloo, London Borough of Lambeth, London SE1, UK"). However, when my server retrieves the results from this url it gets the address "2C Waterloo Rd, London, Greater London NW2 7UA, UK" which is miles away from Waterloo. (It is only returning a single result too.)

My server is based in the UK and doing an GeoIP on the IP confirms this. Why would Google return different results to my server?

(BTW my server is using PHP5 simplexml_load_file() to retrieve the results)

** I don't understand why this question has been marked as a duplicate of another. The question this is a supposed duplicate of does not answer my question in the slightest, my question has nothing to do with businesses (only postal regions) and does not explain why my server is being treated differently to my PC.

buffcoredave
  • 179
  • 1
  • 9

1 Answers1

7

You're experiencing something called Region Biasing: https://developers.google.com/maps/documentation/geocoding/#RegionCodes

Pass a region=uk GET parameter and your results should be the same (i.e. tailored to the UK) everywhere.

Wander Nauta
  • 18,832
  • 1
  • 45
  • 62
  • Sorry I forgot to mention that I have already tried this and nothing changed - I've updated my question to reflect this – buffcoredave Apr 25 '12 at 08:07
  • Thank you, I solved my question here http://stackoverflow.com/questions/30748515/geocoding-a-specific-address-fails-from-php-works-from-browser-using-the-same-u – Marco Marsala Jun 10 '15 at 06:50
  • I found another strange case, using hyphens ' in address leads to different results across geolocation API and Google Maps. Solution was to remove hyphens from address, while accented letters aren't a problem if using urlencode. – Marco Marsala Jun 10 '15 at 07:07