初识ArcGis for android 的IdentitfyTask
来源:互联网 发布:帝国cms 头条 编辑:程序博客网 时间:2024/06/10 19:08
本人第一次试用IdentiFyTask做查询工作,
1.试用了天地图图层,这个是网上下载到的,
2.导入ArcGis for android 的相关jia包
主要代码如下:::
(1)使用AsyncTask进行IdentifyTask 的查询
public class MyIdentifyTask extends AsyncTask<IdentifyParameters, Void, IdentifyResult[]>{
IdentifyTask identifyTask;
private ProgressDialog dialog;
Context context;
MapView map;
Point point;
public MyIdentifyTask(Point point, Context context,MapView map){
this.context = context;
this.map = map;
this.point = point;
}
@Override
protected IdentifyResult[] doInBackground(IdentifyParameters... params) {
IdentifyResult[] mResult = null;
if(params!=null&¶ms.length>0){
try {
mResult = identifyTask.execute(params[0]);
} catch (Exception e) {
e.printStackTrace();
}
}
return mResult;
}
@Override
protected void onPreExecute() {
dialog = ProgressDialog.show(context, "Identify Task", "Identify query ...");
identifyTask = new IdentifyTask("http://221.13.129.100:6080/arcgis/rest/services/ZZWebGisData/MapServer");
}
@Override
protected void onPostExecute(IdentifyResult[] result) {
if(dialog.isShowing()){
dialog.dismiss();
Callout out = map.getCallout();
TextView view = new TextView(context);
if(result.length>0){
view.setText(result[0].getLayerName());
}else{
view.setText("暂无信息");
}
out.setContent(view);
out.show(point);
}
}
}
(2) MainActivity如下
public class MainActivity extends Activity {
private MapView map;
private com.example.identifytask.TianDiTuTiledMapServiceLayer tianDiTuLayer;
private com.example.identifytask.TianDiTuTiledMapServiceLayer tianDiTuLayer2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = (MapView)findViewById(R.id.map);
//添加天地图作为底图图层(使用的上面下载到图层转换代码)
tianDiTuLayer = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.VEC_C);
//添加天地图的标注图层
tianDiTuLayer2 = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.CVA_C);
//添加自己的图层
ArcGISDynamicMapServiceLayer dLayer = new ArcGISDynamicMapServiceLayer("http://221.13.129.100:6080/arcgis/rest/services/ZZWebGisData/MapServer");
//设置地图背景色(不添加地图的时候能够看出来,白色无网格)
map.setMapBackground(0xffffff, 0xffffff, 0, 0);
//去除前面的use only的水印
ArcGISRuntime.setClientId("1eFHW78avlnRUPHm");
map.addLayer(tianDiTuLayer);
map.addLayer(tianDiTuLayer2);
map.addLayer(dLayer);
map.setOnSingleTapListener(new OnSingleTapListener() {
@Override
public void onSingleTap(float x, float y) {
if(!map.isLoaded()){
return;
}
//坐标转换
Point identifyPoint = map.toMapPoint(x, y);
Point point = (Point)GeometryEngine.project(identifyPoint, SpatialReference.create(4490), SpatialReference.create(2383));
IdentifyParameters params = new IdentifyParameters();
params.setGeometry(point);
params.setSpatialReference(SpatialReference.create(2383));
params.setDPI(98);
params.setTolerance(20);
params.setMapHeight(map.getHeight());
params.setMapWidth(map.getWidth());
params.setLayerMode(IdentifyParameters.ALL_LAYERS);
Envelope env = new Envelope();
map.getExtent().queryEnvelope(env);
params.setMapExtent(env);
//实例化自己定义的类
MyIdentifyTask myIdentifyTask = new MyIdentifyTask(identifyPoint,MainActivity.this,map);
myIdentifyTask.execute(params);
}
});
}
}
- 初识ArcGis for android 的IdentitfyTask
- arcgis for js 从入门到放弃二:dojo初识和arcgis的多种写法
- [arcgis for android]arcgis for android 定位
- arcgis for android QueryTask的简单使用
- ArcGIS for Android掩膜技术的应用
- Arcgis for Android Collout的简单使用
- ArcGIS for Android 获取FeatureLayer的图例
- ArcGIS for Android FeatureLayer的属性更新
- ArcGIS for Android FindTask的简单使用
- arcgis for android 整理的samples
- arcgis api for android MapView的索引
- ArcGIS for Android中坐标的转换
- [arcgis for android]arcgis for android 在 Android Studio上的环境配置
- ArcGIS for Android
- arcgis for android 学习
- ArcGis for Android定位
- ARCGIS for android
- 说说arcGIS for Android
- java中Double类数字太大时页面正常显示而不要用科学计数法
- Zoho People-公式让人事工作更简单
- android TextView图文混排
- 面向对象思想概述
- ORACLE基本操作
- 初识ArcGis for android 的IdentitfyTask
- java内存的创建,管理和消亡
- 不懂程序看的明白《黑客帝国》吗?
- 写在前面的话
- 苹果手机DNS怎么设置
- 想要学好C++,必看,能看完,证明你有学习C++的潜质,否则趁早放弃。
- jsp 编译过程
- python3.5[No module named 'encodings']报错
- 【IIS】Windows下利用IIS建立网站并实现局域网共享