How Geolocation Works
Geolocation in the browser almost never uses GPS. Here is how Wi-Fi scanning works, why it's faster and cheaper than satellites, and what each provider actually tells the browser.
I spent years thinking the browser called a GPS satellite when you clicked "Allow" on a location prompt.
It almost never does.
The most common geolocation method on a phone is Wi-Fi scanning -- and you don't even need to be connected to a network for it to work.
Three Ways a Browser Can Find You
GPS
GPS is what most people picture. Your device has a radio that listens for signals from satellites orbiting Earth. To calculate a position, it needs signals from at least four satellites simultaneously. Each satellite broadcasts a precise timestamp. The device measures how long each signal took to arrive, calculates the distance to each satellite, and triangulates a position.
The accuracy is roughly 10 meters for civilians. The military version has higher accuracy -- the civilian signal deliberately has some noise in it.
GPS has two costs. One is time -- when the radio first turns on, it needs to find satellites and establish a fix. This cold start can take anywhere from a few seconds to several minutes depending on conditions. The other is battery -- you're running a dedicated radio to receive signals.
Any null values in the position object are a sign that GPS wasn't the source. coords.altitude and coords.speed are only populated when GPS provides them.
Wi-Fi Scanning (What Actually Happens)
This is the interesting one, and most developers don't know the details.
When you request the user's location, the browser doesn't just look at the Wi-Fi network you're connected to. It scans all visible access points nearby -- every Wi-Fi network the device can detect -- and sends that list to a server.
The list includes metadata for each access point: the SSID (network name), the channel, signal strength, and other identifiers. You don't need to be connected to any of them. The device just reads what's broadcasting nearby.
That list goes to Google (on Chrome/Android) or Apple (on iOS). Their servers look up that specific combination of nearby access points in a database and return a location.
Where does the database come from? Two sources.
Google Street View cars don't just take photos. They also carry a Wi-Fi antenna and GPS. While driving through cities, they record every access point they see alongside its GPS coordinates. That builds a mapping of SSID combinations to physical locations.
The second source is phones themselves. When many users in the same location have Google or Apple location services enabled, their devices report new access points they see. If a new Wi-Fi router appears at a specific location and enough devices report it, it gets added to the database.
This is faster than GPS and cheaper on battery. There's no radio to power up, no cold start, no satellite search. It's a lookup in a database. The location arrives in under a second.
The one scenario where Wi-Fi scanning fails is when you're moving quickly. Driving on a highway at 70 mph, the browser reads access points, sends them to a server, and gets back a location -- but by the time the response arrives, you're already half a mile away. GPS is the only viable option when you're moving fast enough to outpace a network round-trip.
Cell Towers
Cell tower location was used heavily in the early smartphone era. The idea: your phone knows which cell tower it's connected to. If you know where the towers are, you know roughly where the phone is.
The problem is that the phone only knows its cell ID -- a number. The database that maps cell IDs to physical locations lives at the carrier, not on the device. Apple and Google historically negotiated agreements with carriers to share that data. Those agreements are largely no longer in place, and cell tower location is not a method phones typically use today.
The accuracy was always city-level at best. It was a stopgap, not a precision tool.
ExpandThree geolocation providers: GPS, Wi-Fi scanning, and cell towers -- accuracy, battery cost, and how each works
What the Browser Tells You (and What It Doesn't)
The Geolocation API is completely provider-agnostic. You cannot ask for GPS. You cannot ask for Wi-Fi. You ask the browser for a location and it uses whatever method is available and fastest.
The one clue you get is coords.accuracy. This is the estimated radius of uncertainty in meters. A value around 10-20 meters suggests GPS. A value of 50 meters or more strongly suggests Wi-Fi scanning. You can infer the provider from this number, but you can't confirm it.
What the Geolocation API Cannot Do
Two limitations follow directly from how the underlying technology works.
The API is foreground-only. You cannot track a user's location while they're not on your page. No background geolocation, no silent location updates. Native apps can do this with explicit background location permission. Web pages cannot.
Geofencing is not possible. Geofencing lets an app trigger an event when a user enters or exits a geographic area -- "user arrived at the store," "user left the campus." This requires background location tracking. Without it, there's no way to fire the event. Several proposals for web-based geofencing were drafted over the years. None reached maturity.
Both of these are intentional constraints. A website that can silently track your location without being open would be a significant privacy violation. The platform enforces the limitation at the API level -- the same thinking behind the browser permission model that covers all sensitive capabilities.
Understanding how the providers work is one half of geolocation. The other half is the API itself -- two methods, three options, and a position object where null values tell you more than the actual values do.
The Essentials
- Wi-Fi scanning is the default geolocation method on most phones. It's faster and less battery-intensive than GPS, and works indoors where satellites can't reach.
- Wi-Fi scanning works by sending a list of ALL nearby access points to Google/Apple servers. You don't need to be connected to any of them.
- GPS accuracy is ~10 meters. Wi-Fi accuracy is tens of meters.
coords.accuracylets you infer which provider was used, but you can't ask for a specific one. - The Geolocation API is foreground-only -- no background tracking, no geofencing.
- Cell towers were used historically but are not the typical method today -- the location lookup requires carrier database access that devices no longer have.
Further Reading and Watching
- Location without GPS -- How Geolocation works? (YouTube) -- clear explanation of how browser geolocation uses Wi-Fi, GPS, and cell towers to determine location
- Geolocation API -- MDN -- full specification reference covering the API, position object, and error codes
Keep reading