MaxMind GeoIP City Returning Incorrect Lat Longs

593 views Asked by At

I am trying to use MaxMind to get the lat longs based on IPAddress. I am passing in my external IP address (It shows a correct location on MaxMind's website). The problem is it returned Latitude = 38 Longitude = -97 from 3 different users in 3 different cities. It should be Latitude = ~45 and Logitude = ~122. I have updated the GeoLite2-City.mmdb and have updated to the latest version of MaxMind.Db and MaxMind.GeoIP2.

public Location GetLocationFromIpAddress(string ipAddress)
{
    using (var db = new MaxMind.GeoIP2.DatabaseReader(_dbFilePath)) 
    {
        var result = db.City(IPAddress.Parse(ipAddress));
        // result.Location.Latitude = 38
        // result.Location.Longitude = -97
        return new Location
                   {
                       Name = result.MostSpecificSubdivision.Name,
                       Latitude = result.Location.Latitude,
                       Longitude = result.Location.Longitude
                   };
    }
}   
1

There are 1 answers

0
GoodKhaos On

I figured it out, the issue was that I was using the lite version of the database. When I tested it with a full version it gave the correct lat long.