What is geolocation?
Geolocation is finding where a device is in the real world, as coordinates, a city or a country. Phones use GPS, Wi-Fi and cell towers. A website can ask the browser, which needs the visitor's permission, or look up the visitor's IP address on the server, which needs no permission and reaches a city or region at most.
- Sources
- GPS, Wi-Fi, cell towers, IP address
- Returns
- Coordinates, city, country, time zone
- In a browser
- Asks permission, HTTPS only
- From an IP
- No prompt, city or region at most
IP address. Your server looks it up in an IP geolocation database. No permission prompt. Reaches a city or region at most, and some addresses only a country.
How a device's location is found
Each source trades precision for convenience. The ones on the device are the most precise but need the person's permission. The IP address is always available to your server but only reaches a city or region.
| Source | How it works | Permission | How close it gets |
|---|---|---|---|
| GPS | The device reads signals from navigation satellites | Needed | The most precise of the four, best outdoors |
| Wi-Fi | Nearby Wi-Fi networks are matched to a map of where those networks are | Needed | Depends on how many known networks are nearby |
| Cell towers | The phone's position is estimated from the towers it can reach | Needed | The area those towers cover |
| IP address | Your server looks up the visitor's IP address in an IP geolocation database | None | A city or region at most; some addresses only to a country |
Browser or IP address
A website has two ways to find a visitor's location. A site can use both: the IP address for a default, and the browser when the person wants something near them.
Browser Geolocation API
navigator.geolocation.getCurrentPosition( pos => console.log( pos.coords.latitude, pos.coords.longitude, pos.coords.accuracy // meters ) );
- Permission
- The browser asks the visitor first, and works only on HTTPS pages
- Source
- The best source the device has, for example GPS
- Good for
- "Stores near me", maps, delivery tracking
- Limit
- Nothing comes back if the visitor says no
IP geolocation
GET https://api.sthan.io/IpGeolocation/8.8.8.8 { "city": "Mountain View", "region": "California", "postalCode": "94043", "timezone": "America/Los_Angeles", "isp": "Google LLC", "isHosting": true }
- Permission
- None; every request already carries an IP address
- Source
- An IP geolocation database
- Good for
- Language, currency and region defaults, fraud checks, analytics
- Limit
- A VPN or proxy shows where its server is
The response above is a real lookup on the sthan.io API on November 20, 2026, shortened. 8.8.8.8 is Google's public DNS, so isHosting is true. The location belongs to the network and says nothing about a person. Every field explained.
Geolocation, geocoding and reverse geocoding
Geolocation
8.8.8.8 is in Mountain View, CA
Frequently asked questions
What does geolocation mean?
What is the difference between geolocation and IP geolocation?
Does geolocation need the user's permission?
How accurate is geolocation?
What is the difference between geolocation and geocoding?
Is there a free geolocation API?
Related terms
Find where your visitors are
50,000 free IP lookups a month. No credit card.