Geolocation basics

How Browser Geolocation Works

How the browser Geolocation API works: the permission flow, where positions come from (GPS, Wi-Fi, cell towers, IP), accuracy values and secure contexts.

A website asks for your location, you click "Allow", and a second later a map centres on your street. Behind that moment sit a web standard, a permission system, several positioning technologies and, often, a cloud location service. Understanding the chain makes it much easier to see where privacy tools fit in.

The Geolocation API in one paragraph

Browsers implement the W3C Geolocation API (opens in a new tab). It gives pages three methods: getCurrentPosition() for a single reading, watchPosition() for continuous updates, and clearWatch() to stop them. Each successful call delivers a position object with coordinates (latitude, longitude, accuracy, and optionally altitude, altitude accuracy, heading and speed) and a timestamp. Errors come back with one of three codes: permission denied, position unavailable, or timeout.

What happens, step by step

  1. The page calls the API

    Script on the page requests a position, optionally asking for high accuracy, a timeout and the maximum age of a cached answer.

  2. The browser checks the context

    Geolocation is only available in a secure context — HTTPS pages or localhost. Embedded frames also need permission from the embedding page through Permissions Policy.

  3. The browser checks permission

    If you've already allowed or blocked the site, that decision applies. Otherwise the browser shows a prompt. The page can't see or style it.

  4. The browser obtains a position

    It asks the operating system or its own network location provider for a fix, using the sources described below.

  5. The page receives the result

    The callback receives the coordinates. From this moment, the site can use, store or send them anywhere, like any other data.

Where the position comes from

SourceHow it worksTypical accuracy
Satellite (GPS, Galileo, GLONASS, BeiDou)The device's receiver measures signals from satellites. Mostly on phones and tablets; needs a view of the sky.A few metres outdoors
Wi-Fi positioningThe device reports the Wi-Fi networks it can see, with signal strengths, to a location service that knows roughly where those networks are.Tens of metres in cities
Cell towersThe mobile network cells in range are looked up in a database.Hundreds of metres to kilometres
IP address fallbackIf nothing else is available, some providers estimate from the IP address.City or region

Desktop and laptop computers rarely have GPS, so on those machines the result typically comes from Wi-Fi positioning. Chrome's help pages, for example, explain that when you share your location, Chrome sends information to Google Location Services to estimate where you are. Firefox and other browsers use comparable network location providers, or the operating system's own location service, depending on platform and settings.

What the accuracy value means

The accuracy attribute is a radius in metres around the reported point. It expresses the browser's confidence: the true position is expected to lie within that circle. A Wi-Fi fix in a dense city might report 20–40 m; a desktop on a wired connection with no Wi-Fi might report several kilometres because it fell back to a coarse method.

Two points are often misunderstood. First, coordinates are always shown with many decimal places, but the digits don't make the fix more precise — the accuracy value does. Second, accuracy is self-reported. Privacy tools can change it; Location Guard, for instance, enlarges it to reflect the noise it adds. See why browser location can be inaccurate for the common failure modes.

The options pages can set

  • enableHighAccuracy — a hint that the page wants the best possible fix. On phones this can switch on satellite positioning, which costs time and battery.
  • timeout — how long the page is willing to wait before getting a timeout error.
  • maximumAge — how old a cached position may be. A non-zero value lets the browser answer instantly with a recent fix.

Checking permission without asking

The Permissions API (opens in a new tab) lets a page ask whether geolocation is currently granted, denied or prompt without triggering a prompt. Support and behaviour vary between browsers; some decline to report the state in certain situations. Our permission checker shows what your browser reports.

Where privacy tools fit in

There are three points in the chain where you can intervene:

  1. Permission — deny the request, or block requests by default. The site gets nothing.
  2. Positioning — turn off OS location services, or limit an app to approximate location on mobile platforms that support it.
  3. The result — tools such as Location Guard sit between the browser and the page and alter the coordinates before the page sees them.

None of these affect your IP address, which every site can see. That is a separate channel, explained in browser geolocation vs IP geolocation.

Try it yourself

Our browser location test calls getCurrentPosition() with the options above and shows every field the browser returns. The accuracy test uses watchPosition() to show how readings change over time.

Frequently asked questions

Does browser geolocation use GPS?

It can, on devices that have a satellite receiver, such as phones. On most desktop and laptop computers, the position comes from Wi-Fi positioning or the operating system's location service instead.

Why do browsers require HTTPS for geolocation?

Location is sensitive. Restricting the API to secure contexts prevents attackers on the network from injecting scripts into unencrypted pages to request it, and assures you which site is asking.

Can a website track my location continuously?

With permission, a page can use watchPosition() to receive updates while it is open, although browsers may pause or throttle updates in background tabs. Updates stop when you close the page or revoke the permission.