← Sensors & Location
Geolocation
Probing…Geolocation is a web platform capability in the Sensors & Location category. Current position and continuous location watching. Supported in Chromium 5+, Firefox 3.5+, and Safari 5+. Requires a secure context (HTTPS or localhost) and a user gesture such as a click or tap.
Secure contextUser gesture
Permission geolocation: unknown
Try it
Loading demo…
Code
// One-shot read
navigator.geolocation.getCurrentPosition(
pos => console.log(pos.coords.latitude, pos.coords.longitude),
err => console.warn(err.code, err.message),
{ enableHighAccuracy: true, timeout: 10000 },
)
// Live updates
const id = navigator.geolocation.watchPosition(pos => update(pos.coords))
// later: navigator.geolocation.clearWatch(id)Browser support
Chromium
5
Firefox
3.5
Safari
5
Frequently asked questions
Which browsers support Geolocation?
Supported in Chromium 5+, Firefox 3.5+, and Safari 5+.
Does Geolocation require HTTPS?
Yes. Geolocation needs a secure context, so it only works over HTTPS (or on localhost during development).
What is Geolocation used for?
Current position and continuous location watching.
Can I try Geolocation in my browser?
Yes. shwcs.net runs a live Geolocation demo that probes your current browser and lets you try the API. Everything runs locally — nothing is sent anywhere.