Search code examples
geolocation

How to get the location of a web request?


What's the best way to get the location (to a country level) of where a web request is coming from?


Solution

  • There are 3 ways, generally speaking:

    • Use GeoIP or some similar database or service which maps IPs to physical locations
    • Use the W3C geolocation api (supported by newer browsers only)
    • Google gears geolocation