Sensors / 05

Geolocation.

Latitude, longitude, altitude, heading, speed, and accuracy from the browser's geolocation API. Tests your device's GPS fix quality.

Notes

The accuracy number reveals the fix source: under 50 m = GPS, under 500 m = Wi-Fi triangulation, over 500 m = IP-only.

How it works

We call navigator.geolocation.getCurrentPosition() with enableHighAccuracy: true. The browser surfaces a permission prompt the first time, then queries the OS, which routes to GPS, Wi-Fi triangulation, or IP geolocation depending on availability.

The headline metric is the accuracy radius — a smaller number is a tighter fix. The position is never sent anywhere; it's surfaced only in the result panel and your browser's clipboard if you press Copy.

Frequently asked

What does the accuracy number mean?

It's the radius (in meters) of the 68% confidence circle around your reported position. Under 50 m typically means a GPS fix on a phone outdoors. 50-500 m means Wi-Fi triangulation (the browser sent nearby SSIDs to Google's location DB and got a guess back). Over 500 m is IP-only geolocation — accurate to the ISP's exchange, not your house.

Why is altitude and heading often null?

Altitude needs a clear GPS sky view. Heading and speed need recent positional movement to compute from. On a stationary device or one indoors, the OS returns null for those fields rather than guessing.

Does this work indoors?

Yes, but accuracy drops sharply. GPS signals struggle to reach indoor receivers, so the OS falls back to Wi-Fi triangulation (typically 50-500 m). For better indoor accuracy, enable Bluetooth — many beacons cross-reference into the location DB.

Why does my browser ask for permission?

Geolocation reveals your physical location, which is sensitive. Browsers gate the API behind explicit permission per origin. Accept once per site and the browser remembers it for the session.

Is enableHighAccuracy worth it?

On phones, yes — it tells the OS to activate the GPS chip rather than relying on cached Wi-Fi triangulation. It's slower (5-15 seconds for first fix) and uses more battery, but accuracy improves from ~100m to ~5m. We pass enableHighAccuracy: true.

Can a website see my location without asking?

No. Modern browsers absolutely require a permission prompt before geolocation works. Even fingerprinting techniques (timezone, language, IP) only narrow you down to a city, not a GPS coordinate.