Windows Mobile引路蜂地图开发示例:IP地址查询

IP地址查询,可以根据IP地址查询到该IP所在的地理经纬度坐标,比如下述例子查询IP 地址58.192.32.1,所在经纬度为118.777802,32.061699,为南京大学所在地。

在MainForm上添加mnuIPSearch菜单。并在MainForm中实现IIpAddressGeocodingListener接口用于响应查询结果

public void Done(string query, IpAddressLocation result) 
{ 
 if (result != null && result.Error.Length == 0 
  && result.Longitude.Length > 0 
  && result.Latitude.Length > 0) 
 { 
  try
  { 
  
   MapPoint mapPoint = new MapPoint(); 
   String latLng = "[" + result.Longitude + ","
     + result.Latitude + ",0]"; 
   mapPoint.Point = DigitalMap.FromStringToLatLng(latLng); 
   mapPoint.Name = (result.Organization); 
   mapPoint.ObjectNote = (result.City + " " + result.Country); 
   _rasterMap.PanTo(mapPoint.Point); 
  } 
  catch (Exception e) 
  { 
  
   result.Error = "IP_NOT_FOUND"; 
  } 
 } 
} 
  
.... 
private void mnuIPSearch_Click(object sender, EventArgs e) 
{ 
 _rasterMap.GetIpLocations("58.192.32.1"); 
}


注:目前IP查询结果总是以英文返回,如上述结果详细内容。
ISP:”China Education and Research Network”
Organization: “Nan Jing University”
Country: “CN”
City: “Nanjing”
若想知道该经纬度对应的地名,可以使用地址反编码服务。
你可以输入 127.0.0.1 查询本机地址。

Windows Mobile引路蜂地图开发包Ver2.1下载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值