← Glossary

What Is Geolocation Access?

Geolocation access is the permission-gated route through which a page requests device position from the browser Geolocation API. It needs a secure context, permission and an available position estimate, and is separate from IP-based location lookup.

Updated:

Geolocation access is what a website obtains when the user allows it to read the device's position through the browser. The mechanism is the Geolocation API: a page calls a method to request the current position or to watch it over time, the browser checks the site's permission and may ask the user to grant it, and if the answer is yes the browser consults the operating system's location services and returns coordinates with an accuracy estimate. Three conditions sit in front of every result. The page must be loaded in a secure context, the user or a saved decision must grant permission, and the device must actually be able to determine where it is. The arrangement differs from IP-based estimates in every respect: those are made by the server from the connection's address, need no permission, and cannot be refused by denying the browser prompt.

Permission Requests and Secure Contexts

MDN documents the flow directly. Because geolocation data may reveal information the device owner does not want to share, users must grant explicit permission via a prompt when either getCurrentPosition() or watchPosition() is called, unless the permission state is already granted or denied. The lifetime of that decision is up to the browser: it may last for the session, for a fixed period or permanently, and users can change it later through site settings. The Permissions API exposes the current state as granted, denied or prompt, which lets a page avoid asking again when the answer is already known.

Browser geolocation works only in secure contexts, normally HTTPS or a potentially trustworthy local-development context, with the surrounding context also relevant. On an insecure page the API may not be exposed at all; an application should check availability before expecting a position or error callback. Embedded frames add a further gate: the Permissions Policy directive for geolocation defaults to an allowlist of self, so a cross-origin iframe cannot use the API unless the embedding page delegates it with an allow attribute and, where set, the policy header permits it. Geolocation access is therefore granted per site, per context and per frame, not to the browser as a whole.

Position Results, Accuracy and Errors

A successful call delivers a position object containing coordinates and a timestamp. The coordinates carry latitude and longitude in decimal degrees, an accuracy value in metres describing the estimated uncertainty of that fix, and optional altitude, altitude accuracy, heading and speed that are null when the device cannot supply them. The browser decides which sources to use: satellite positioning, nearby Wi-Fi networks, cell towers or, as a last resort, the connection's address. The page cannot assume which source produced a result. MDN notes that Wi-Fi-based positioning is often provided by an external service, which is why results differ between browsers and regions.

Three options shape the request. enableHighAccuracy is a hint that the page would like the most precise fix available; the specification says the implementation may ignore it and warns that it can slow responses and increase power use. timeout caps how long the page will wait, excluding time spent waiting for the user to answer the prompt. maximumAge allows a cached position no older than the stated number of milliseconds, trading freshness for speed.

Failures arrive through an error callback with one of three codes.

ErrorCodeTypical cause
PERMISSION_DENIED1User refused, policy blocked the frame, or required location access is disallowed
POSITION_UNAVAILABLE2No location source could produce a fix, such as when positioning sources are unavailable
TIMEOUT3No fix within the requested time

A page that treats every error as refusal misreads the second and third cases, which are about the device and environment rather than the user's choice.

Browser Location Access Compared With IP Geolocation

The two routes to a location answer different questions and should not be conflated.

  • Who decides. Browser location access requires the user's grant; an IP estimate is made by the server from the request's source address without any interaction.
  • What is measured. The API reports an estimate supplied by the browser's location provider, potentially combining several sources; an IP lookup reports where a database places the network's exit address.
  • Precision. A successful sensor-based fix can be much more precise than an IP estimate, but hardware, surroundings and provider policy determine the uncertainty. IP estimates can be wrong or unavailable.
  • Effect of a proxy or VPN. A genuine sensor-derived fix usually remains tied to the device; an IP-derived estimate follows the exit address. API results that use network information can differ.
  • Effect of denying permission. The API returns an error; the IP estimate is unchanged, because the server never needed the browser's cooperation.

A consequence worth stating plainly: denying permission blocks this API route, but not an IP estimate or location information the visitor supplies another way. A VPN changes the apparent connection address without necessarily changing a granted sensor-derived estimate. Sites that compare the two can notice the discrepancy.

Where Access Is Requested

Maps and navigation need continuous updates and use watchPosition(). Store locators, delivery estimates and weather pages need a single fix and use getCurrentPosition(), often with a generous maximumAge. Ride-hailing and check-in features request high accuracy. Fraud and compliance systems in some regulated services request location to confirm a jurisdiction, typically alongside the IP estimate rather than instead of it. Good practice, reflected in the specification's guidance, is to request access only when the feature needs it, in response to a user action, with a visible explanation, and to fall back gracefully when it is refused.

Limits and Privacy Settings

Access is only as good as the device's sources. Indoors, in dense cities or on hardware without GPS, the browser may return a coarse Wi-Fi or cell fix with a large accuracy value, or fail entirely. Operating systems let users disable location services globally or per application, which may block or limit the browser's location provider despite the site permission. Some browsers and privacy settings reduce the precision reported to websites. Location permission settings therefore exist at three layers, the operating system, the browser and the individual site, and any one of them can withhold data.

The data itself is sensitive: a precise fix reveals where someone is, and a watched sequence reveals where they go. The specification's requirement for explicit permission and secure contexts reflects that, and a site should retain and use the result only for the purpose explained to the visitor. Geolocation access gives a site a measurement under the user's control; it does not give it the user's identity, it does not persist beyond what the site stores, and permission can be withdrawn. Blocking the permission prevents later access, while resetting it may cause a new prompt; neither action deletes coordinates the site already received.

Frequently asked questions

Can a website estimate location without this permission?

Yes. A server can estimate the connection's location from its IP address without this API permission, with accuracy that varies. It may also know an address the visitor submitted. Denying geolocation blocks the browser API, not every possible location inference.

Can users revoke permission?

Yes. Users can block or reset a site's location permission and change operating-system access. Blocking prevents new API access; resetting may prompt again. Revocation does not erase coordinates the site already received or stored.

Why can geolocation requests fail indoors?

Satellite signals are blocked or distorted inside buildings, so the device falls back to Wi-Fi and cell data. If those sources are unavailable or not in the positioning database, the browser returns a position-unavailable error or a fix with a large accuracy value.

Why does geolocation only work on HTTPS pages?

Geolocation is a secure-context feature, normally used on HTTPS with a local-development exception. In insecure contexts the API may be unavailable, so code must check before calling it. Secure transport reduces ordinary network tampering with requests and results.

Can an embedded iframe request location?

Only if the embedding page allows it. The Permissions Policy directive for geolocation defaults to same-origin frames, so a cross-origin iframe needs an explicit allow attribute, and the top-level page's policy header can still forbid it.