What's the most accurate way to determine user geolocation in the browser?
-
19-09-2019 - |
Question
I found a few examples suggesting Google AJAX APIs.
This link typifies the advice I have found so far: http://briancray.com/2009/05/29/find-web-visitors-location-javascript-google-api/
However, the location is often wrong with the Google APIs.
Other sites seem to know exactly which city I'm in, though, without me entering any information.
Suggestions? Is there something cross-browser (ignoring IE6) and reliable?
Solution
I was going to answer with a few points but sometimes referencing a decent article is the way to go. I recently came across this Smashing Magazine article by Christian Heilmann which explains the issues, solutions and further info on all things GeoLocational.
OTHER TIPS
check http://hostip.info it is an opensource database.
Other that the costly GeoIP database and the limited js api, (cited in the smash article Brian linked) MaxMind also offers a number of free Geolite DBs, for download.
http://www.maxmind.com/app/geolitecity
They are redistributable under this license.
Try Webshims geolocation module it implements navigator.geolocation API if browser doesn't support it.