ArcGIS for Android示例解析之高亮要素-----HighlightFeatures
转自:http://blog.csdn.net/wozaifeiyang0/article/details/7323606
HighlightFeatures
要素高亮化功能,相信有其他gis开发经营的开发人员都有过相应的实现经验,对于高亮要素,简单说起来就是我们查询的或识别出来的要素进行渲染,让其突出显示而已,这个例子中涉及后面要介绍的识别的内容,我们只简单介绍相关的知识,主要介绍要素对象的渲染(也就是所谓的高亮),来看代码:
|
mapView.setOnLongPressListener(new OnLongPressListener() { public void onLongPress(float x,float y) { try { if (tiledMapServiceLayer.isInitialized() && selectedLayerIndex >= 0) { graphicsLayer.removeAll(); /* *点击地图的点 */ Point pointClicked = mapView.toMapPoint(x, y); /* * 识别任务所需的参数,初始化相应的值 */ IdentifyParameters inputParameters = new IdentifyParameters(); inputParameters.setGeometry(pointClicked); inputParameters.setLayers(new int[] { layerIndexes[selectedLayerIndex] }); Envelope env = new Envelope(); mapView.getExtent().queryEnvelope(env); inputParameters.setSpatialReference(mapView.getSpatialReference()); inputParameters.setMapExtent(env); inputParameters.setDPI(96); inputParameters.setMapHeight(mapView.getHeight()); inputParameters.setMapWidth(mapView.getWidth()); inputParameters.setTolerance(10); /* * 这是我们自己扩展的类,在其中主要实现了IdentifyTask的请求 */ MyIdentifyTask mIdenitfy = new MyIdentifyTask(); //执行异步操作并将参数传入异步操作中 mIdenitfy.execute(inputParameters); } else { Toast toast = Toast.makeText(getApplicationContext(), "Please select a layer to identify features from.", Toast.LENGTH_SHORT); toast.show(); } } catch (Exception ex) { ex.printStackTrace(); } } }); |
上面的代码中,主要给地图添加了一个长按地图事件监听,在事件处理函数中主要做了初始化识别任务的参数及其执行我们扩展的MyIdentifyTask操作,MyIdentifyTask其实就是一个异步请求类,下面我们来看看,这异步请求类做了什么,代码如下:
|
private class MyIdentifyTask extends AsyncTask<IdentifyParameters, Void, IdentifyResult[]> { IdentifyTask mIdentifyTask; @Override protected IdentifyResult[] doInBackground(IdentifyParameters... params) { IdentifyResult[] mResult = null; if (params != null && params.length > 0) { IdentifyParameters mParams = params[0];//获取参数 try { mResult = mIdentifyTask.execute(mParams);//执行识别操作 } catch (Exception e) { e.printStackTrace(); } } return mResult; } @Override protected void onPostExecute(IdentifyResult[] results) { // TODO Auto-generated method stub if (results != null && results.length > 0) { //生成要素对象数组 highlightGraphics = new Graphic[results.length]; Toast toast = Toast.makeText(getApplicationContext(), results.length + " features identified\n", Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM, 0, 0); toast.show(); for (int i = 0; i < results.length; i++) { Geometry geom = results[i].getGeometry(); String typeName = geom.getType().name(); //在这里我们进行要素的高亮显示,也就是要素渲染工作 Random r = new Random(); int color = Color.rgb(r.nextInt(255), r.nextInt(255), r.nextInt(255)); if (typeName.equalsIgnoreCase("point")) { SimpleMarkerSymbol sms = new SimpleMarkerSymbol(color, 20, STYLE.SQUARE); highlightGraphics[i] = new Graphic(geom, sms); } else if (typeName.equalsIgnoreCase("polyline")) { SimpleLineSymbol sls = new SimpleLineSymbol(color, 5); highlightGraphics[i] = new Graphic(geom, sls); } else if (typeName.equalsIgnoreCase("polygon")) { SimpleFillSymbol sfs = new SimpleFillSymbol(color); sfs.setAlpha(75); highlightGraphics[i] = new Graphic(geom, sfs); } graphicsLayer.addGraphic(highlightGraphics[i]); clearButton.setEnabled(true); } } else { Toast toast = Toast.makeText(getApplicationContext(), "No features identified.", Toast.LENGTH_SHORT); toast.show(); } } @Override protected void onPreExecute() { mIdentifyTask = new IdentifyTask(mapURL);//初始化识别任务实例 } } |
在这里我们可以看到,这个异步类主要做了实例化识别任务对象,并且执行识别任务,返回的结果再进行渲染显示,对于Android中的异步类AsyncTask应该有所了解吧,简单介绍一下他的执行过程,当我们生成AsyncTask实例并执行execute()方法后,他的内部还是执行顺序为onPreExecute()à doInBackground()àonPostExecute()
这样我们的高亮功能示例就介绍完成了,要想实现不同的、五彩缤纷的效果那就需要我们深入了解要素的渲染类及其相关的特性。
ArcGIS for Android示例解析之高亮要素-----HighlightFeatures的更多相关文章
- ArcGIS for Android示例解析之空间查询-----QueryTask
转自:http://blog.csdn.net/wozaifeiyang0/article/details/7331450 QueryTask 查询功能在GIS中是一个不可或缺的重要功能,示例中提供了 ...
- ArcGIS for Android示例解析之离线地图-----LocalTiledLayer
转自:http://blog.csdn.net/wozaifeiyang0/article/details/7327423 LocalTiledLayer 看到这个标题是否是很激动,如题,该示例就是添 ...
- Arcgis for android 离线查询
参考.. 官方API demo ... 各种资料 以及.. ArcGIS for Android示例解析之高亮要素-----HighlightFeatures ttp://blog.csdn.net/ ...
- ArcGIS for Android离线数据编辑实现原理
来自:http://blog.csdn.net/arcgis_mobile/article/details/7565877 ArcGIS for Android中现已经提供了离线缓存图片的加载功能,极 ...
- ArcGIS for Android地图控件的5大常见操作
GIS的开发中,什么时候都少不了地图操作.ArcGIS for Android中,地图组件就是MapView,MapView是基于Android中ViewGroup的一个类(参考),也是ArcGIS ...
- ArcGIS for Android学习(一)
GIS的开发中,什么时候都少不了地图操作.ArcGIS for Android中,地图组件就是MapView,MapView是基于Android中ViewGroup的一个类(参考),也是ArcGIS ...
- 外业数据采集平台(GPS+Android Studio+Arcgis for android 100.2.1)
外业数据采集平台 1. 综述 在室外,通过平板或者手机接收GPS坐标,实时绘制点.线.面数据,以便为后续进行海域监测.土地确权.地图绘图提供有效数据和依据. 2. 技术路线 Android studi ...
- arcgis for android常见问题回答
Q:arcgis for android最新版本是多少?(2014-7-18) Arcgis for android 10.2.3 sdk 百度盘下载地址:http://pan.baidu.com/s ...
- 【Arcgis for android】相关教程收集自网络
请加入qq群:143501213 一起交流和学习 推荐博客: 张云飞VIR http://www.cnblogs.com/vir56k/tag/arcgis%20for%20android/ arcg ...
随机推荐
- JSONP(跨域请求) —— 一种非官方跨域数据交互协议
1.JSONP的作用 由于同源策略的限制,XmlHttpRequest只允许请求当前源(域名.协议.端口)的资源,为 了实现跨域请求,可以通过script标签实现跨域请求,然后再服务器端输出JSON数 ...
- 网站重构-你了解AJAX吗?
AJAX是时下最流行的一种WEB端开发技术,而你真正了解它的一些特性吗?--IT北北报 XMLHTTPRequest(XHR)是目前最常用的技术,它允许异步接收和发送数据,所有的主流浏览器都对它有不错 ...
- C语言基础知识-循环结构
用while打印出1~100之间7的倍数 int i = 1; while循环是当条件表达式的结果为真时,执行大括号里面的循环体,重复执行直到条件表达式的结果为假时结束循环. w ...
- bug - colorWithPatternImage:
// 在ios5之前, 再通过以下方法设置背景时, 有闪屏bug self.view.backgroundColor = [UIColor colorWithPatternImage:<#(no ...
- VS Extension: Create a txt file and set the content
使用 Visual Studio Extension 创建一个文本文件,并填入内容. 需要引用 EnvDTE C:\Program Files (x86)\Microsoft Visual Studi ...
- 《ASP.NET 本质论》HttpApplication的处理管道 ,HttpMoudle,HttpHandler
http://blog.csdn.net/sky1069/article/details/6659667 handler :http://blog.csdn.net/keymo_/article/de ...
- HttpOnly
Contents 1 Overview 1.1 Who developed HttpOnly? When? 1.2 What is HttpOnly? 1.3 Mitigating the Most ...
- HDU2167+状态压缩DP
状态压缩dp 详见代码 /* 状态压缩dp dp[ i ][ j ]:第i行j状态的最大和 dp[i][j] = max( dp[i-1][k]+sum[i][j] ); 题意:给定一个N*N的方格, ...
- POJ2200+全排列模拟
简单. 手动的实现全排列 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<a ...
- explain 用法详解
explain显示了mysql如何使用索引来处理select语句以及连接表.可以帮助选择更好的索引和写出更优化的查询语句. 使用方法,在select语句前加上explain就可以了: 如: expla ...