So far I know how to grab the client location to a application or web application by using the users geolocation or GPS location. I remember the possibility of finding the users approximate location by using their IP address. How is this done if you know how it is done can you link me to a tutorial or spec in addition to a short description?

Edit (Added Picture):
enter image description here

Edit: Possibly found through ISP?

5 Answers 5


There's a good explanation at this blog post There are essentially four ways it's done by browsers.

  1. GPS. Duh
  2. AGPS. Use phone towers to triangulate the position
  3. WiFi. Use available known wifi networks to triangulate the position
  4. IP Address databases. As has been noted above.
  • +1 Thanks, It looks like Geolocation uses 1-3 and is agnostic to the underlying sources of location information according to its requirements. That was one interesting article. Once again thanks!
    – dkroy
    Commented Jul 25, 2011 at 7:29

Try Maxmind's GeoIP or Quova's webservices. They have free and paid databases of ip address ranges to approx lat/lon.

  • Thanks this answer got me on the correct track I believe.
    – dkroy
    Commented Jul 24, 2011 at 8:01

Due to Ragi's links in his answer I was able to piece together how the IP Address location is done. The 3rd party organizations have a Database mapping where there is some relation to the location to the ISP and as a result IP ranges. This seems to be a dying technique since HTML5 is becoming more supported and GPS's are being put into more and more portable devices.

The three client locating techniques:
1. GPS Location (GPS integrated devices)
2. Geolocation (HTML5 enabled browsers/devices)
3. ISP-Location database mappings (Third Party API's)

IP to Location Libraries/API:
GeoBytes - PHP/Web Service

I am going to leave this question open for a day since I may be wrong and I will probably no longer be using this third technique in concert with Geolocation.


Despite I agree that GPS location is the best, but most website are still accesed from desktop or laptop devices. Laptops can figure out an approximate location based on wireless networks, but the user have to give his consent that his location is traced. I bet that 50% won't do this unless they really know what you do with their location. IF you want to trace it to give him differential content or targeted ads then he probably won't accept.

If you have a service that need exact location then you can ask for their permission, if not, then they can leave as your service is based on the location.

If you want to know their location for other purpose: content, ads, statistics, then the best way is to use a geolocation API, so you don't have to hassle with all the database thing. I've noticed that the ipgp geolocation API to be the most accurate: http://www.ipgp.net/ip-address-geolocation-api/


you can look this extension for gps web gate... mobile-gps-web-gate

and i use this code for my mobile app....

// navigator.geolocation.getCurrentPosition(successCallback, errorCallback, options)
navigator.geolocation.getCurrentPosition(function(position) {
      var location = [position.address.city, position.address.region, position.address.country].join(', ');
      createMap(position.latitude, position.longitude, location);
}, function() {
      document.getElementById('cantfindyou').innerHTML = "We dont find you!";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.