W3C Geolocation API
   HOME

TheInfoList



OR:

The W3C Geolocation API is an effort by the
World Wide Web Consortium The World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web. Founded in 1994 and led by Tim Berners-Lee, the consortium is made up of member organizations that maintain full-time staff working ...
(W3C) to standardize an interface to retrieve the geographical location information for a client-side device. It defines a set of objects,
ECMAScript ECMAScript (; ES) is a JavaScript standard intended to ensure the interoperability of web pages across different browsers. It is standardized by Ecma International in the documenECMA-262 ECMAScript is commonly used for client-side scripti ...
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 An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
(API). The most common sources of location information are
IP address An Internet Protocol address (IP address) is a numerical label such as that is connected to a computer network that uses the Internet Protocol for communication.. Updated by . An IP address serves two main functions: network interface ident ...
,
Wi-Fi Wi-Fi () is a family of wireless network protocols, based on the IEEE 802.11 family of standards, which are commonly used for local area networking of devices and Internet access, allowing nearby digital devices to exchange data by radio waves ...
and
Bluetooth Bluetooth is a short-range wireless technology standard that is used for exchanging data between fixed and mobile devices over short distances and building personal area networks (PANs). In the most widely used mode, transmission power is limi ...
MAC address A media access control address (MAC address) is a unique identifier assigned to a network interface controller (NIC) for use as a network address in communications within a network segment. This use is common in most IEEE 802 networking te ...
,
radio-frequency identification Radio-frequency identification (RFID) uses electromagnetic fields to automatically Automatic identification system, identify and Tracking system, track tags attached to objects. An RFID system consists of a tiny radio transponder, a radio receiver ...
(RFID), Wi-Fi connection location, or device
Global Positioning System The Global Positioning System (GPS), originally Navstar GPS, is a satellite-based radionavigation system owned by the United States government and operated by the United States Space Force. It is one of the global navigation satellite ...
(GPS) and
GSM The Global System for Mobile Communications (GSM) is a standard developed by the European Telecommunications Standards Institute (ETSI) to describe the protocols for second-generation ( 2G) digital cellular networks used by mobile devices such ...
/
CDMA Code-division multiple access (CDMA) is a channel access method used by various radio communication technologies. CDMA is an example of multiple access, where several transmitters can send information simultaneously over a single communicatio ...
cell IDs. The location is returned with a given accuracy depending on the best location information source available. The result of W3C Geolocation API will usually give 4 location properties, including
latitude In geography, latitude is a coordinate that specifies the north– south position of a point on the surface of the Earth or another celestial body. Latitude is given as an angle that ranges from –90° at the south pole to 90° at the north ...
and
longitude Longitude (, ) is a geographic coordinate that specifies the east– west position of a point on the surface of the Earth, or another celestial body. It is an angular measurement, usually expressed in degrees and denoted by the Greek let ...
(coordinates), altitude (height), and ccuracy of the position gathered which all depend on the location sources. In some queries, altitude may yield or return no value.


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 Gears, formerly Google Gears, is discontinued utility software offered by Google to create more powerful web apps by adding offline storage and other additional features to web browsers. Released under the BSD license, Gears is free and open-sou ...
plugin, but this was discontinued in 2010 and the server-side API it depended on stopped responding in 2012. The Geolocation API is ideally suited to web applications for mobile devices such as
personal digital assistant A personal digital assistant (PDA), also known as a handheld PC, is a variety mobile device which functions as a personal information manager. PDAs have been mostly displaced by the widespread adoption of highly capable smartphones, in part ...
s (PDA) and
smartphone A smartphone is a portable computer device that combines mobile telephone and computing functions into one unit. They are distinguished from feature phones by their stronger hardware capabilities and extensive mobile operating systems, whi ...
s. On desktop computers, the W3C Geolocation API works in
Firefox Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements current ...
since version 3.5,
Google Chrome Google Chrome is a cross-platform web browser developed by Google. It was first released in 2008 for Microsoft Windows, built with free software components from Apple WebKit and Mozilla Firefox. Versions were later released for Linux, macOS, ...
,
Opera Opera is a form of theatre in which music is a fundamental component and dramatic roles are taken by singers. Such a "work" (the literal translation of the Italian word "opera") is typically a collaboration between a composer and a libr ...
10.6,
Internet Explorer Internet Explorer (formerly Microsoft Internet Explorer and Windows Internet Explorer, commonly abbreviated IE or MSIE) is a series of graphical web browsers developed by Microsoft which was used in the Windows line of operating systems (in ...
9.0, and Safari 5. On mobile devices, it works on Android (firmware 2.0+), iOS,
Windows Phone Windows Phone (WP) is a discontinued family of mobile operating systems developed by Microsoft for smartphones as the replacement successor to Windows Mobile and Zune. Windows Phone featured a new user interface derived from the Metro design lan ...
and
Maemo Maemo is a software platform originally developed by Nokia, now developed by the community, for smartphones and Internet tablets. The platform comprises both the Maemo operating system and SDK. Maemo played a key role in Nokia's strategy to c ...
. The W3C Geolocation API is also supported by Opera Mobile 10.1 – available for Android and
Symbian Symbian is a discontinued mobile operating system (OS) and computing platform designed for smartphones. It was originally developed as a proprietary software OS for personal digital assistants in 1998 by the Symbian Ltd. consortium. Symbian OS ...
devices (S60 generations 3 & 5) since 24 November 2010. Browsers initially allowed access to the API in insecure contexts, but in the context of Secure Contexts, browsers, e.g., Chrome, now generally require a secure connection.
Google Gears Gears, formerly Google Gears, is discontinued utility software offered by Google to create more powerful web apps by adding offline storage and other additional features to web browsers. Released under the BSD license, Gears is free and open-sou ...
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 Windows Mobile is a discontinued family of mobile operating systems developed by Microsoft for smartphones and personal digital assistants. Its origin dated back to Windows CE in 1996, though Windows Mobile itself first appeared in 2000 as Pock ...
. However, the Google Gears Geolocation API is incompatible with the W3C Geolocation API and is no longer supported.


Location sources

The Geolocation API does not provide the location information. The location information is obtained by a device (such as a smartphone, PC or modem), which is then served by the API to be brought in browser. Usually geolocation will try to determine a device's position using one of these several methods. ;GPS (Global Positioning System): This happens for any device which has GPS capabilities. A smartphone with GPS capabilities and set to high accuracy mode will be likely to obtain the location data from this. GPS calculate location information from the satellite signal. It has the highest accuracy; in most Android smartphones, the accuracy can be up to 10 metres. ;Mobile Network Location:
Mobile phone tracking Mobile phone tracking is a process for identifying the location of a mobile phone, whether stationary or moving. Localization may be effected by a number of technologies, such as the multilateration of radio signals between (several) cell towers ...
is used if a cellphone or wireless modem is used without a GPS chip built in. ;Wi-Fi Positioning System: If Wi-Fi is used indoors, a Wi-Fi positioning system is the likeliest source. Some Wi-Fi spots have location services capabilities. ;IP Address Location: Location is detected based on the nearest public IP address on a device (which can be a computer, the router it is connected to, or the
Internet Service Provider An Internet service provider (ISP) is an organization that provides services for accessing, using, or participating in the Internet. ISPs can be organized in various forms, such as commercial, community-owned, non-profit, or otherwise priva ...
(ISP) the router uses). The location depends on the IP information available, but in many cases where the IP is hidden behind an ISP network address translation, the accuracy is only to the level of a city, region or even country.


Implementation

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 uses Google's network location provider. 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 (code.l.google.com). 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 JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other se ...
) 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.


Example code

Simple
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of websites use JavaScript on the client side for webpage behavior, of ...
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 : const geoFindMe = () => const success = (position) => const error = (error) => const geoOptions = ;


See also

*
Local search (Internet) Local search is the use of specialized Internet search engines that allow users to submit geographically constrained searches against a structured database of local business listings. Typical local search queries include not only information abou ...
*
Location-based service A location-based service (LBS) is a general term denoting software services which use geographic data and information to provide services or information to users. LBS can be used in a variety of contexts, such as health, indoor object search, en ...


References


External links


W3C Geolocation API Specification
{{Web interfaces Application programming interfaces HTML5 Internet geolocation Location-based software Web standards