Android IP查询实例
来源:互联网 发布:淘宝客户问卷调查 编辑:程序博客网 时间:2024/04/29 06:24
IP地址查询,可以根据IP地址查询到该IP所在的地理经纬度坐标,比如下述例子查询IP 地址58.192.32.1,所在经纬度为118.777802,32.061699。
Java代码:
复制到剪贴板 Java代码
1. package eoe.demo;
2.
3.
4.
5. import com.mapdigit.gis.DigitalMap;
6.
7. import com.mapdigit.gis.MapPoint;
8.
9. import com.mapdigit.gis.geometry.GeoLatLng;
10.
11. import com.mapdigit.gis.service.IIpAddressGeocodingListener;
12.
13. import com.mapdigit.gis.service.IpAddressLocation;
14.
15. import com.pstreets.gisengine.R;
16.
17. import com.pstreets.gisengine.SharedMapInstance;
18.
19.
20.
21. import android.app.Activity;
22.
23. import android.os.Bundle;
24.
25. import android.view.Menu;
26.
27. import android.view.MenuInflater;
28.
29. import android.view.MenuItem;
30.
31.
32.
33. public class MapIpSearch extends Activity implements
34.
35. IIpAddressGeocodingListener {
36.
37.
38.
39. @Override
40.
41. public void onCreate(Bundle savedInstanceState) {
42.
43. super.onCreate(savedInstanceState);
44.
45. setContentView(R.layout.main);
46.
47. }
48.
49.
50.
51. @Override
52.
53. public void onStart() {
54.
55. super.onStart();
56.
57. GeoLatLng center = new GeoLatLng(32.0616667, 118.7777778);
58.
59. SharedMapInstance.map.setCenter(center, 15,
60.
61. com.mapdigit.gis.raster.MapType.MICROSOFTCHINA);
62.
63. SharedMapInstance.map.setIpAddressGeocodingListener(this);
64.
65.
66.
67. }
68.
69.
70.
71. @Override
72.
73. public boolean onCreateOptionsMenu(Menu menu) {
74.
75. MenuInflater inflater = getMenuInflater();
76.
77. inflater.inflate(R.menu.mapgeocoding_menu, menu);
78.
79. return true;
80.
81. }
82.
83.
84.
85. @Override
86.
87. public boolean onOptionsItemSelected(MenuItem item) {
88.
89. switch (item.getItemId()) {
90.
91. case R.id.findaddress:
92.
93. SharedMapInstance.map.getIpLocations("58.192.32.1");
94.
95. return true;
96.
97.
98.
99. default:
100.
101. return super.onOptionsItemSelected(item);
102.
103. }
104.
105.
106.
107. }
108.
109.
110.
111. @Override
112.
113. public void done(String query, IpAddressLocation result) {
114.
115. if (result != null && result.error.length() == 0
116.
117. && result.longitude.length() > 0
118.
119. && result.longitude.length() > 0) {
120.
121. try {
122.
123.
124.
125. MapPoint mapPoint = new MapPoint();
126.
127. String latLng = "[" + result.longitude + "," + result.latitude+ ",0]";
128.
129. mapPoint.point = DigitalMap.fromStringToLatLng(latLng);
130.
131. mapPoint.setName(result.organization);
132.
133. mapPoint.setNote(result.city + " " + result.country);
134.
135. SharedMapInstance.map.panTo(mapPoint.point);
136.
137. } catch (Exception e) {
138.
139.
140.
141. result.error = "IP_NOT_FOUND";
142.
143. }
144.
145. }
146.
147.
148.
149. }
150.
151.
152.
153. @Override
154.
155. public void readProgress(int bytes, int total) {
156.
157.
158.
159. }
160.
161.
162.
163. }
164.
- Android IP查询实例
- Android中由IP地址查询经纬度坐标的实例
- C#实现根据域名查询ip实例
- C#实现根据域名查询ip实例
- IP138 IP地址查询 php实例
- PHP调用淘宝IP地址查询接口查询IP所在地信息实例
- C#实现根据域名查询ip实例(原创)
- IP查询
- IP查询
- ip查询
- ip查询
- 查询Ip
- 查询Ip
- 查询Ip
- 查询Ip
- 查询Ip
- 查询Ip
- 查询Ip
- 今天是开通博客第一天
- 车牌识别,移植到android系统
- wps如何插入Word里的行前小黑圆点
- myeclipse+CVS的全套配置+(附:解决)Error validating location问题
- 黑马程序员 java高级技术1.5之枚举(张孝祥)
- Android IP查询实例
- FreeConsole() 函数可以隐藏控制台
- 1、机器学习-Linear regresstion with one varible
- Replica Set 副本集
- 谨慎使用时间ID
- 在mac电脑配置环境变量的方法
- Web Components是不是Web的未来
- 2014一世依旧
- android多媒体本地播放流程video playback--base on jellybean (三)