World Library  
Flag as Inappropriate
Email this Article

W3C Geolocation API

Article Id: WHEBN0023521191
Reproduction Date:

Title: W3C Geolocation API  
Author: World Heritage Encyclopedia
Language: English
Subject: HTML5 File API, Open Web Platform, Web worker, HTML5 video, Scalable Vector Graphics
Collection: Application Programming Interfaces, Geolocation, Web Standards
Publisher: World Heritage Encyclopedia

W3C Geolocation API

The W3C Geolocation API is an effort by the World Wide Web Consortium (W3C) to standardize an interface to retrieve the geographical location information for a client-side device.[1] It defines a set of objects, ECMAScript standard compliant, that executing in the client application give the client's device location through the consulting of Location Information Servers, which are transparent for the application programming interface (API). The most common sources of location information are IP address, Wi-Fi and Bluetooth MAC address, radio-frequency identification (RFID), Wi-Fi connection location, or device Global Positioning System (GPS) and GSM/CDMA cell IDs. The location is returned with a given accuracy depending on the best location information source available.


  • Deployment in web browsers 1
  • Features 2
  • Implementation 3
    • Example code 3.1
  • See also 4
  • External Links 5
  • References 6

Deployment in web browsers

Web pages can use the Geolocation API directly if the web browser implements it. Historically, some browsers could gain support via the Google Gears plugin[2] but this was discontinued in 2010 and the server-side API it depended on stopped responding in 2012.[3]

The Geolocation API is ideally suited to web applications for mobile devices such as personal digital assistants (PDA) and smartphones. However, there is not yet widespread support on such platforms due to the wide variety of devices and mobile browsers, which usually lack a plugin architecture. On desktop computers, the W3C Geolocation API works in Firefox since version 3.5, Google Chrome,[4] Opera 10.6,[5] Internet Explorer 9.0,[6] and Safari 5. On mobile devices, it works on Android (firmware 2.0 +), iOS, Windows Phone and Maemo. The W3C Geolocation API is also supported by Opera Mobile 10.1 — available for Android and Symbian devices (S60 generations 3 & 5) since November 24, 2010.[7]

Google Gears provided geolocation support for older and non-compliant browsers, including Internet Explorer 7.0+ as a Gears plugin, and Google Chrome which implemented Gears natively. It also supported geolocation on mobile devices as a plugin for the Android browser (pre version 2.0) and Opera Mobile for Windows Mobile. The Google Gears Geolocation API is incompatible with the W3C Geolocation API.


The result of W3C Geolocation API will usually give 4 location properties, including latitude and longitude (coordinates), altitude (height), and accuracy of the position gathered.


Though the implementation is not specified, W3C Geolocation API is built on extant technologies, and is heavily influenced by Google Gears Geolocation API. Example: Firefox's Geolocation implementation[8] uses Google's network location provider.[9]

Google Gears Geolocation works by sending a set of parameters that could give a hint as to where the user's physical location is to a network location provider server, which is by default the one provided by Google ([10] Some of the parameters are lists of sensed mobile cell towers and Wi-Fi networks, all with sensed signal strengths. These parameters are encapsulated into a JavaScript Object Notation (JSON) message and sent to the network location provider via HTTP POST. Based on these parameters, the network location provider can calculate the location. Common uses for this location information include enforcing access controls, localizing and customizing content, analyzing traffic, contextual advertising and preventing identity theft.[11]

Example code

Simple JavaScript code that checks if the browser has the Geolocation API implemented and then uses it to get the current position of the device. this code creates a function which can be called on html using :

function geoFindMe(){

          navigator.geolocation.getCurrentPosition(success, error, geo_options);
          alert("Geolocation services are not supported by your web browser.");
function success(position) {
 var latitude = position.coords.latitude;
 var longitude = position.coords.longitude;
 var altitude = position.coords.altitude;
 var accuracy = position.coords.accuracy;
 //do something with above position thing e.g. below
 alert('I am here! lat:' + latitude +' and long : ' +longitude );
function error(error) {
 alert("Unable to retrieve your location due to "+error.code + " : " + error.message);
var geo_options = {
 enableHighAccuracy: true,
 maximumAge : 30000,
 timeout : 27000

See also

External Links

  • W3C Geolocation API Specification


  1. ^ Popescu, Andrei (editor, Google Inc.) (22 December 2008). "Geolocation API Specification: W3C Candidate Recommendation 07 September 2010". W3C. Retrieved 7 July 2009. 
  2. ^ "Geolocation API: Gears API: Google Code". 9 July 2009. 
  3. ^ GeolocationAPI - gears - Provides the geolocation of a device running a Gears-enabled web browser. - Improving Your Web Browser - Google Project Hosting. Retrieved on 2014-06-01.
  4. ^ "A new Chrome stable release: Welcome, Mac and Linux!". 25 May 2010. 
  5. ^ Kleinhout, Huib (1 July 2010). "Opera 10.60 goes final".  
  6. ^ "W3C Geolocation API in IE9". 
  7. ^ (2010-11-25). "Opera Mobile 10.1 for Nokia smartphones goes final". 
  8. ^ "Location-Aware Browsing". Mozilla Firefox. Mozilla. 
  9. ^ "Geolocation API Network Protocol: Gears API". Google Code. Google. Retrieved 8 August 2011. 
  10. ^ " W3C Geolocation API". 
  11. ^ King, Kevin F. (8 June 2010). "Personal Jurisdiction, Internet Commerce, and Privacy: The Pervasive Legal Consequences of Modern Geolocation Technologies". 
  1. How to Implement a W3C Geolocation API in Javascript
  2. an W3C Geolocation displayed on Google MapsWhere Am I -
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.