W3C Geolocation API

Last updated

Geolocation API
First published22 December 2008;15 years ago (2008-12-22) [1] [2]
Latest versionW3C Recommendation
1 September 2022;21 months ago (2022-09-01) [3]
Organization
CommitteeGeolocation Working Group [3]
EditorsAndrei Popescu [3]
Domain Geographical location information
Website www.w3.org/TR/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. [3] 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.

Contents

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], which all depend on the location sources.[ citation needed ]

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, but this was discontinued in 2010 and the server-side API it depended on stopped responding in 2012. [4] [5]

The Geolocation API is ideally suited to web applications for mobile devices such as smartphones. On desktop computers, the W3C Geolocation API works in Firefox since version 3.5, Google Chrome, [6] Opera 10.6, [7] Internet Explorer 9.0, [8] 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 24 November 2010. [9] Browsers initially allowed access to the API in insecure contexts, but in the context of Secure Contexts, [10] browsers, e.g., Chrome, [11] now generally require a secure connection.

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. 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 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 (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 [12] uses Google's network location provider. [5] 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). [13] 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. [14]

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 <body onload="geoFindMe()">:

constgeoFindMe=()=>{if(navigator.geolocation){navigator.geolocation.getCurrentPosition(success,error,geoOptions);}else{console.log("Geolocation services are not supported by your web browser.");}}constsuccess=(position)=>{constlatitude=position.coords.latitude;constlongitude=position.coords.longitude;constaltitude=position.coords.altitude;constaccuracy=position.coords.accuracy;console.log(`lat: ${latitude} long: ${longitude}`);}consterror=(error)=>{console.log(`Unable to retrieve your location due to ${error.code}: ${error.message}`);}constgeoOptions={enableHighAccuracy:true,maximumAge:30000,timeout:27000};

See also

Related Research Articles

<span class="mw-page-title-main">Browser wars</span> Competition between web browsing applications for share of worldwide usage

A browser war is a competition for dominance in the usage share of web browsers. The "first browser war" (1995–2001) consisted of Internet Explorer and Netscape Navigator, and the "second browser war" (2004-2017) between Internet Explorer, Firefox, and Google Chrome.

Google Toolbar was a web browser toolbar for Internet Explorer, developed by Google. It was first released in 2000 for Internet Explorer 5. Google Toolbar was also distributed as a Mozilla plug-in for Firefox from September 2005 to June 2011. On December 12, 2021, the software was no longer available for download, and the website now redirects to a support page.

<span class="mw-page-title-main">Mobile browser</span> Web browser designed for use on mobile devices

A mobile browser is a web browser designed for use on a mobile device such as a mobile phone, PDA, smartphone, or tablet. Mobile browsers are optimized to display web content most effectively on small screens on portable devices. Some mobile browsers, especially older versions, are designed to be small and efficient to accommodate the low memory capacity and low bandwidth of certain wireless handheld devices. Traditional smaller feature phones use stripped-down mobile web browsers; however, most current smartphones have full-fledged browsers that can handle the latest web technologies, such as CSS 3, JavaScript, and Ajax.

In computing, Internet geolocation is software capable of deducing the geographic position of a device connected to the Internet. For example, the device's IP address can be used to determine the country, city, or ZIP code, determining its geographical location. Other methods include examination of Wi-Fi hotspots, a MAC address, image metadata, or credit card information.

<span class="mw-page-title-main">Mobile web</span> Mobile browser-based World Wide Web services

The mobile web comprises mobile browser-based World Wide Web services accessed from handheld mobile devices, such as smartphones or feature phones, through a mobile or other wireless network.

A browser extension is a software module for customizing a web browser. Browsers typically allow users to install a variety of extensions, including user interface modifications, cookie management, ad blocking, and the custom scripting and styling of web pages.

Gears, formerly Google Gears, is a 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-source. Gears was conceived at a time when a comparable alternative was not available. However, Gears was discontinued in favor of the standardized HTML5 methods that eventually became prevalent.

Real-time geotagging refers to the automatic technique of acquiring media, associating a specific location with the media, transferring the media to an online map and publishing the media in real time. It is thus an extension of an automatic geotagging process, requiring an in-built or attached location acquisition device, but also requires communication with a wireless data transfer device. Most modern smartphones and several digital cameras already integrate camera, aGPS, and wireless data transfer into one device, thus directly producing a geotagged photograph. Real-time geotagging is sometimes referred to as "mobile geotagging" or "autogeotagging", but this does not imply the real-time publishing step.

<span class="mw-page-title-main">Navizon</span> American provider of location-based services

Navizon, Inc. is a provider of location-based services and products. Navizon was an early developer of technology that makes it possible to determine the geographic position of a mobile device using as reference the location of cell phone towers and Wi-Fi-based wireless access points instead of GPS. Navizon also developed technology for locating mobile devices indoors with room and floor-level accuracy.

Web storage, sometimes known as DOM storage, is a standard JavaScript API provided by web browsers. It enables websites to store persistent data on users' devices similar to cookies, but with much larger capacity and no information sent in HTTP headers. There are two main web storage types: local storage and session storage, behaving similarly to persistent cookies and session cookies respectively. Web Storage is standardized by the World Wide Web Consortium (W3C) and WHATWG, and is supported by all major browsers.

<span class="mw-page-title-main">WebGL</span> JavaScript bindings for OpenGL in web browsers

WebGL is a JavaScript API for rendering interactive 2D and 3D graphics within any compatible web browser without the use of plug-ins. WebGL is fully integrated with other web standards, allowing GPU-accelerated usage of physics, image processing, and effects in the HTML canvas. WebGL elements can be mixed with other HTML elements and composited with other parts of the page or page background.

A GSM Cell ID (CID) is a generally unique number used to identify each base transceiver station (BTS) or sector of a BTS within a location area code (LAC) if not within a GSM network.

WebRTC is a free and open-source project providing web browsers and mobile applications with real-time communication (RTC) via application programming interfaces (APIs). It allows audio and video communication and streaming to work inside web pages by allowing direct peer-to-peer communication, eliminating the need to install plugins or download native apps.

Content Security Policy (CSP) is a computer security standard introduced to prevent cross-site scripting (XSS), clickjacking and other code injection attacks resulting from execution of malicious content in the trusted web page context. It is a Candidate Recommendation of the W3C working group on Web Application Security, widely supported by modern web browsers. CSP provides a standard method for website owners to declare approved origins of content that browsers should be allowed to load on that website—covered types are JavaScript, CSS, HTML frames, web workers, fonts, images, embeddable objects such as Java applets, ActiveX, audio and video files, and other HTML5 features.

HTML audio is a subject of the HTML specification, incorporating audio input, playback, and synthesis, all in the browser.

Encrypted Media Extensions (EME) is a W3C specification for providing a communication channel between web browsers and the Content Decryption Module (CDM) software which implements digital rights management (DRM). This allows the use of HTML video to play back DRM-wrapped content such as streaming video services without the use of heavy third-party media plugins like Adobe Flash or Microsoft Silverlight. The use of a third-party key management system may be required, depending on whether the publisher chooses to scramble the keys.

Mozilla Location Service (MLS) is an open geolocation service which allows devices to find their position by processing their received signals of publicly observable radio transmitters: cellular network antennae, Wi-Fi access points, and Bluetooth beacons. The service is provided by Mozilla since 2013. The service uses Mozilla's open source software project called Ichnaea.

WebXR Device API is a Web application programming interface (API) that describes support for accessing augmented reality and virtual reality devices, such as the HTC Vive, Oculus Rift, Oculus Quest, Google Cardboard, HoloLens, Apple Vision Pro, Magic Leap or Open Source Virtual Reality (OSVR), in a web browser. The WebXR Device API and related APIs are standards defined by W3C groups, the Immersive Web Community Group and Immersive Web Working Group. While the Community Group works on the proposals in the incubation period, the Working Group defines the final web specifications to be implemented by the browsers.

<span class="mw-page-title-main">Progressive web app</span> Specific form of single page web application

A progressive web application (PWA), or progressive web app, is a type of application software delivered through the web, built using common web technologies including HTML, CSS, JavaScript, and WebAssembly. It is intended to work on any platform with a standards-compliant browser, including desktop and mobile devices.

WebGPU is a JavaScript API provided by a web browser that enables webpage scripts to efficiently utilize a device's graphics processing unit (GPU). This is achieved with the underlying Vulkan, Metal, or Direct3D 12 system APIs. On relevant devices, WebGPU is intended to supersede the older WebGL standard.

References

  1. "Geolocation API Specification 2nd Edition Publication History - W3C". n.d. Retrieved 21 April 2021.
  2. Popescu, Andrei (22 December 2008). "Geolocation API Specification". W3C. Geolocation Working Group. Retrieved 21 April 2021.
  3. 1 2 3 4 Cáceres, Marcos; Grant, Reilly (1 September 2022). "Geolocation API Specification". W3C. Geolocation Working Group. Retrieved 8 February 2024.
  4. "Geolocation API: Gears API: Google Code". Google Code. 9 July 2009. Archived from the original on 14 February 2012. Retrieved 21 April 2021.
  5. 1 2 "GeolocationAPI - gears - Provides the geolocation of a device running a Gears-enabled web browser. - Improving Your Web Browser - Google Project Hosting". Google Code. n.d. Archived from the original on 22 December 2015. Retrieved 21 April 2021.
  6. "A new Chrome stable release: Welcome, Mac and Linux!". Google Chrome Blog. 25 May 2010. Retrieved 21 April 2021.
  7. Kleinhout, Huib (1 July 2021). "Opera 10.60 goes final". My Opera . Opera Software. Archived from the original on 9 November 2011. Retrieved 21 April 2021.
  8. ieblog (17 February 2011). "W3C Geolocation API in IE9 - IEBlog - Site Home - MSDN Blogs". IEBlog. Archived from the original on 19 February 2011. Retrieved 21 April 2021.
  9. Opera.com (25 November 2010). "Opera speeds up Symbian browsing". Archived from the original on 4 November 2011. Retrieved 21 April 2021.
  10. "Secure Contexts". W3.org. Retrieved 13 October 2022.
  11. "Intent to Remove: Insecure origin usage of geolocation". Groups.Google.com. Retrieved 13 October 2022.
  12. "Does Firefox share my location with websites? | Mozilla Support". Mozilla Firefox. Mozilla. n.d. Retrieved 21 April 2021.
  13. "WebScanNotes.com: W3C Geolocation API". WebScanNotes. n.d. Archived from the original on 12 November 2012. Retrieved 21 April 2021.
  14. King, Kevin F. (8 June 2010). "Personal Jurisdiction, Internet Commerce, and Privacy: The Pervasive Legal Consequences of Modern Geolocation Technologies" (published 9 June 2010). SSRN   1622411 . Retrieved 21 April 2021.