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 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.


The Geolocation interface neither implements, nor inherits any property.


The Geolocation interface doesn't inherit any method.

Geolocation.getCurrentPosition() Secure context
Determines the device's current location and gives back a Position 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().


Specification Status Comment
Geolocation API Recommendation Initial specification.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support5123.519


10.6 — 15

Secure context required50 ?55 No37 Yes
clearWatch5 Yes3.59


10.6 — 15

getCurrentPosition5 Yes3.59


10.6 — 15

watchPosition5 Yes3.59


10.6 — 15

FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes12415 Yes Yes
Secure context required51250 ?5537 Yes ?
clearWatch Yes Yes Yes415 Yes Yes
getCurrentPosition Yes Yes Yes415 Yes Yes
watchPosition Yes ? Yes415 Yes Yes

1. GPSD (GPS daemon) support added in Firefox 3.6. WiFi-based location is provided by Google (privacy) or a custom provider (MLS instructions).

2. Secure context is only required for applications targeting Android Nougat (7) and higher. See bug 603574.

See also

Document Tags and Contributors

Last updated by: connorshea,