7

What do people use to geo-locate a persons IP to determine the city they are in?

I've tried the built in functionality of Google API but its geo-location database seem spotty.

http://code.google.com/apis/ajax/documentation/#ClientLocation

Anyone use any other service for geo-locating with success?

splattne
  • 102,760
  • 52
  • 202
  • 249

4 Answers4

5

The most stable company I've seen that does it is MaxMind.

A buddy of mine is using is with success.

Allain Lalonde
  • 91,574
  • 70
  • 187
  • 238
  • 1
    There is a free version available which is a little hard to find since it isn't accessible from the top or side navigation it seems. http://www.maxmind.com/app/geolitecity – DavGarcia Jan 21 '09 at 07:58
3

There is a community-based Geotargeting service from hostip.info. They have a nice clean API for Geotargeted IP Address Lookup. They've got over 8.6 million entries in their database.

Example:

http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true
  Country: UNITED STATES (US)
  City: Sugar Grove, IL
  Latitude: 41.7696
  Longitude: -88.4588

if you add just call:

http://api.hostip.info/?ip=12.215.42.19

You'll get an XML document back.

Source: Scott Hanselman - The Weekly Source Code 37 - Geolocation/Geotargeting (Reverse IP Address Lookup) in ASP.NET MVC made easy

splattne
  • 102,760
  • 52
  • 202
  • 249
2

I've used IPInfoDB (which may use the same database as MaxMind) which has straightforward XML and JSON formats to their API, along with Google's ClientLocation. Neither is perfect and they often disagree. I haven't really found one to be better than the other.

npdoty
  • 4,729
  • 26
  • 25
0

I'm using Codehelper.io Their PHP Class is nice, they can detect real IP for you, and get location , returned JSON with country, city, latidude, calling code, user's languages and more.

They also support Javascript. Check out example at their site.

<?php
// Required Libraries
require_once("ip.codehelper.io.php");
require_once("php_fast_cache.php");

// New Class
$_ip = new ip_codehelper();

// Detect Real IP Address & Location
$real_client_ip_address = $_ip->getRealIP();
$visitor_location       = $_ip->getLocation($real_client_ip_address);

// Output result
echo $visitor_location['Country']."";
echo "<pre>";
print_r($visitor_location);
Ken Le
  • 1,787
  • 2
  • 22
  • 34