The Geolocation API

The geolocation API lets you share your location with trusted websites. The latitude and longitude are available to JavaScript on the page, which in turn can send that information back to the remote web server and do fancy location-aware things like finding local businesses or showing your location on a map.

As you can see from Table 6-1, the geolocation API is supported in several major browsers on desktops and mobile devices. Additionally, some older browsers and devices can be supported by wrapper libraries, as we’ll see later in this chapter.

Table 6-1. Geolocation API support

IE

Firefox

Safari

Chrome

Opera

iPhone

Android

·

3.5+

5.0+

5.0+

·

3.0+

2.0+

Along with support for the standard geolocation API, there are a plethora of device-specific APIs on other mobile platforms. I’ll cover all that later in this chapter.

Get HTML5: Up and Running now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.