This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The Geolocation interface represents an object able to obtain the position of the device programmatically. It gives Web content access to the location of the device. This allows a website or app to offer customized results based on the user's location.
An object with this interface is obtained using the navigator.geolocation property implemented by the Navigator object.
Note: For security reasons, when a web page tries to access location information, the user is notified and asked to grant permission. Be aware that each browser has its own policies and methods for requesting this permission.
The Geolocation interface neither implements, nor inherits any property.
The Geolocation interface doesn't inherit any method.
Geolocation.getCurrentPosition()Determines the device's current location and gives back a GeolocationPosition object with the data.
Geolocation.watchPosition()Returns a long value representing the newly established callback function to be invoked whenever the device location changes.
Geolocation.clearWatch()Removes the particular handler previously installed using watchPosition().
| Specification |
|---|
| Geolocation> # geolocation_interface> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
Geolocation |
5 | 12 | 3.5GPSD (GPS daemon) support added in Firefox 3.6. WiFi-based location is provided by Google (privacy) or a custom provider (MLS instructions). |
10.6 | 5 | 18 | 4 | 11 | ≤3 | 1.0 | 4.4 | ≤3 |
clearWatch |
5 | 12 | 3.5 | 10.6 | 5 | 18 | 4 | 11 | ≤3 | 1.0 | 4.4 | ≤3 |
getCurrentPosition |
5 | 12 | 3.5 | 10.6 | 5 | 18 | 4 | 11 | ≤3 | 1.0 | 4.4 | ≤3 |
secure_context_required |
50 | 79 | 55 | 37 | 10 | 50 | 55 | 37 | 10 | 5.0 | 51Secure context is only required for applications targeting Android Nougat (7) and higher. See bug 40465140. |
10 |
watchPosition |
5 | 12 | 3.5 | 10.6 | 5 | 18 | 4 | 11 | ≤3 | 1.0 | 4.4 | ≤3 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Geolocation