Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

8. Geolocation > 8.2. Getting Basic Geolocation Data with a Fallback

8.2. Getting Basic Geolocation Data with a Fallback

Problem

You want to determine a user’s Internet location when that user’s browser does not support the HTML5 Geolocation API natively.

Solution

Perform an IP-to-location lookup as a fallback. It’s certainly not as accurate as latitude and longitude coordinates, but it’s far better than not having any location data at all.

Google versus MaxMind

Google offers the google.loader.ClientLocation object in its Google Maps API v3 library, but it does not work for many US IP addresses.

The MaxMind GeoIP JavaScript Web Service seems more accurate and up-to-date. Also, it’s free as long as you link back to the http://www.maxmind.com website. Alternatively, MaxMind offers a JavaScript attribution-free license that can be purchased for $250/year.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial