What it is
While the API is consistent across devices, how a given device determines its position is not. There are a number of different ways to determine (such as GPS) or infer (IP address, RFID, Wi-Fi and Bluetooth MAC addresses, etc.) location. Not all methods are available to all devices, and some of them are (far) more accurate than others.
The geolocation API is implemented as a new property on the navigator object:
Source: Geolocation API Specification. W3C Proposed Recommendation 10 May 2012
Where it can be used
- Chrome 5.0+
- Firefox 3.5+
- Internet Explorer 9.0+
- Opera 10.6+
- Safari 5.0+
- Android 2.0+
- iPhone 3.0+
- Opera Mobile 10.1+
How to detect it
Source: Dive Into HTML5
Known issues and concerns
Since sharing the physical location of one’s device has obvious privacy concerns, the geolocation API is explicitly opt-in. All user agents must first obtain permission to share via a user interface (similar, but not consistent across all devices).
Internet Explorer 9 appears to have some accuracy issues when determining latitude and longitude. For more information, see this Microsoft TechNet forum thread.
Source: When can I use…
- Primarily for mobile websites/widget applications. Includes support for Blackberry OS, Nokia, webOS, browsers with Google Gears support and more.
While any of the Source links included above can be used for more information, the following are what I consider the best concise sources to learn more about using the geolocation API:
- Dive Into HTML5. No. 6. You are Here (and so is Everybody Else)
- HTML5 Doctor. Finding your position with Geolocation
Last updated on 12 July 2012.
Please add any updates or corrections in the comments section below. Thanks!