Secure contextThis feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The Geolocation
interface represents an object able to programmatically obtain the position of the device. It gives Web content access to the location of the device. This allows a Web site 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.
Properties
The Geolocation
interface neither implements, nor inherits any property.
Methods
'The Geolocation
interface doesn't inherit any method.
Geolocation.getCurrentPosition()
Secure context- Determines the device's current location and gives back a
GeolocationPosition
object with the data. Geolocation.watchPosition()
Secure context- Returns a
long
value representing the newly established callback function to be invoked whenever the device location changes. Geolocation.clearWatch()
Secure context- Removes the particular handler previously installed using
watchPosition()
.
Specifications
Specification | Status | Comment |
---|---|---|
Geolocation API | Recommendation | Initial specification. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Geolocation
|
Chrome
Full support 5 |
Edge
Full support 12 |
Firefox Full support 3.5 Full support 3.5 Notes' GPSD (GPS daemon) support added in Firefox 3.6. WiFi-based location is provided by Google (privacy) or a custom provider (MLS instructions). |
IE
Full support 9 |
Opera
Full support 10.6 |
Safari
Full support 5 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 11 |
Safari iOS
Full support 5 |
Samsung Internet Android
Full support 1.0 |
clearWatch
|
Chrome
Full support 5 |
Edge
Full support 12 |
Firefox
Full support 3.5 |
IE
Full support 9 |
Opera
Full support 10.6 |
Safari
Full support 5 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 11 |
Safari iOS
Full support 5 |
Samsung Internet Android
Full support 1.0 |
getCurrentPosition
|
Chrome
Full support 5 |
Edge
Full support 12 |
Firefox
Full support 3.5 |
IE
Full support 9 |
Opera
Full support 10.6 |
Safari
Full support 5 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 11 |
Safari iOS
Full support 5 |
Samsung Internet Android
Full support 1.0 |
Secure context required | Chrome
Full support 50 |
Edge
Full support ≤79 |
Firefox
Full support 55 |
IE
No support No |
Opera
Full support 37 |
Safari
Full support Yes |
WebView Android Full support 51 Full support 51 Notes' Secure context is only required for applications targeting Android Nougat (7) and higher. See bug 603574. |
Chrome Android
Full support 50 |
Firefox Android
Full support 55 |
Opera Android
Full support 37 |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support 5.0 |
watchPosition
|
Chrome
Full support 5 |
Edge
Full support 12 |
Firefox
Full support 3.5 |
IE
Full support 9 |
Opera
Full support 10.6 |
Safari
Full support 5 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 11 |
Safari iOS
Full support 5 |
Samsung Internet Android
Full support 1.0 |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.'
- See implementation notes.
See also
Geolocation by Mozilla Contributors is licensed under CC-BY-SA 2.5.