问题
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®ion=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.
回答1:
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.
来源:https://stackoverflow.com/questions/10302302/google-geocoding-api-giving-different-results-to-my-server-and-my-web-browser