【发布时间】:2019-02-21 06:20:21
【问题描述】:
他们是通过 ZipCode 而不是 Ipaddress 从 MaxmindDb 获取 Lat Long 的一种方式。因为我找不到任何通过邮政编码获取详细信息的方法。我不想使用 Google Maps Api。
using (var reader = new DatabaseReader(System.Web.Hosting.HostingEnvironment.MapPath("~/GeoLite2-City.mmdb")))
{
var city = reader.City(userIpAddress);
string cityiso = string.Empty;
if (city != null && !string.IsNullOrEmpty(city.City.Name) && !string.IsNullOrEmpty(city.MostSpecificSubdivision.IsoCode))
{
cityiso = string.Join(", ", city.City.Name, city.MostSpecificSubdivision.IsoCode);
}
locationProperties.Location = cityiso;
locationProperties.Latitude = city.Location.Latitude.ToString();
locationProperties.Longitude = city.Location.Longitude.ToString();
}
但我想使用 UserZipCode 而不是 UserIPAddress
【问题讨论】:
-
如果他们的web site resources 没有回答您的问题,这几乎是一个产品支持问题。这假设您必须使用 Maxmind(相对于 Maxmind 专注于地理位置与安全/IP 焦点的任何其他服务)
-
我在他们的论坛上提出了问题,但我没有提出我的要求。
标签: asp.net-mvc geoip maxmind geoip2 geolite2