MaxMind GeoIP City返回不正确的Lat Longs

时间:2015-06-12 20:03:55

标签: geolocation ip geoip maxmind

我正在尝试使用MaxMind来获取基于IPAddress的lat long。我正在传递我的外部IP地址(它在MaxMind的网站上显示了正确的位置)。问题是它从3个不同城市的3个不同用户返回Latitude = 38 Longitude = -97。它应该是Latitude = ~45和Logitude = ~122。我更新了GeoLite2-City.mmdb并更新到最新版本的MaxMind.Db和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 个答案:

答案 0 :(得分:0)

我明白了,问题是我使用的是精简版的数据库。当我用完整版测试它时,它给出了正确的纬度。