ArcGIS 中UniqueValueRenderer和SimpleRenderer的异同点
唯一值渲染器:UniqueValueRenderer用符号表示一组有匹配属性的图形,这通常用于名词或字符串数据。SimpleRenderer是使用单一符号进行着色分类,不涉及对要素的数据进行处理。这种专题图同一个图层内的所有元素都是一种符号。通过SimpleRenderer对象对Symbol进行设置后,赋予FeatureLayer接口的Renderer属性就可以了。
ESRI.ArcGIS.Client.UniqueValueInfo info = new UniqueValueInfo();
info.Value = "";
info.Symbol = this.CreateSymbolFromEmbedFile("GQYPGIS.MapElement.Symbols.BayonetSymbol.xml"); ESRI.ArcGIS.Client.UniqueValueInfo info1 = new UniqueValueInfo();
info.Value = "";
info.Symbol = this.CreateSymbolFromEmbedFile("GQYPGIS.MapElement.Symbols.CameraSymbol.xml"); ESRI.ArcGIS.Client.UniqueValueInfo info2 = new UniqueValueInfo();
info.Value = "";
info.Symbol = this.CreateSymbolFromEmbedFile("GQYPGIS.MapElement.Symbols.CameraSymbol.xml"); ESRI.ArcGIS.Client.UniqueValueInfo info3 = new UniqueValueInfo();
info.Value = "";
info.Symbol = this.CreateSymbolFromEmbedFile("GQYPGIS.MapElement.Symbols.CameraSymbol.xml"); ESRI.ArcGIS.Client.UniqueValueRenderer renderer = new ESRI.ArcGIS.Client.UniqueValueRenderer();
renderer.Field = "CAMERATYPE";
renderer.Infos.Add(info); this.Renderer = renderer; public Symbol CreateSymbolFromEmbedFile(string embedFile)
{
Assembly ass = Assembly.GetExecutingAssembly();
System.IO.UnmanagedMemoryStream ums = ass.GetManifestResourceStream(embedFile) as System.IO.UnmanagedMemoryStream;
byte[] bytes = new byte[ums.Length];
ums.Read(bytes, , (int)ums.Length);
string xmlString = System.Text.Encoding.UTF8.GetString(bytes);
xmlString = System.Text.RegularExpressions.Regex.Replace(xmlString, "^[^<]", "");
byte[] datas = System.Text.Encoding.ASCII.GetBytes(xmlString);
System.IO.MemoryStream ms = new MemoryStream(datas);
MarkerSymbol symbol = new MarkerSymbol();
symbol.ControlTemplate = (ControlTemplate)System.Windows.Markup.XamlReader.Load(ms);
return symbol; }
在上述的例子中,this代表的是一个继承自FeatureLayer的摄像机图层,这里也列出 GQYPGIS.MapElement.Symbols.CameraSymbol.xml里面的具体内容,这里面把从该xml文件读取相应的ControlTemplate并作为UniqueValueInfo的Symbol
<ControlTemplate
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="http://schemas.esri.com/arcgis/client/2009" > <Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected" />
<VisualState x:Name="Selected">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="MarkerSymbolVideoImg1">
<DiscreteObjectKeyFrame KeyTime="" Value="{x:Static Visibility.Hidden}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="MarkerSymbolVideoImg2">
<DiscreteObjectKeyFrame KeyTime="" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Image Name="MarkerSymbolVideoImg1" Source="/GQYPGIS;component/Source/Image/point_video.png" Visibility="Visible" Width="" Height="" />
<Image Name="MarkerSymbolVideoImg2" Source="/GQYPGIS;component/Source/Image/point_video_hit.png" Visibility="Hidden" Width="" Height="" />
</Grid> </ControlTemplate>
这里必须注意的是要把该xml文件设置成一种嵌入式资源来进行使用,否则是不能正常使用的。其实SimpleRender的用法差不错,也是将获取到的Symbol赋值给SimpleRender的一个对象,下面贴出部分代码。
Assembly ass = Assembly.GetExecutingAssembly();
System.IO.UnmanagedMemoryStream ums = ass.GetManifestResourceStream("ServerShell.ServerWindows.IGIS.MapElement.Symbols.BayonetSymbol.xml") as System.IO.UnmanagedMemoryStream;
byte[] bytes = new byte[ums.Length];
ums.Read(bytes, , (int)ums.Length);
string xmlString = System.Text.Encoding.UTF8.GetString(bytes);
xmlString = System.Text.RegularExpressions.Regex.Replace(xmlString, "^[^<]", "");
xmlString = xmlString.Replace("Width=\"6\"", "Width=\"" + size.ToString() + "\"");
xmlString = xmlString.Replace("Height=\"6\"", "Height=\"" + size.ToString() + "\""); byte[] datas = System.Text.Encoding.ASCII.GetBytes(xmlString);
System.IO.MemoryStream ms = new System.IO.MemoryStream(datas);
MarkerSymbol symbol = new MarkerSymbol();
symbol.ControlTemplate = (System.Windows.Controls.ControlTemplate)System.Windows.Markup.XamlReader.Load(ms);
this.Renderer = new SimpleRenderer()
{
Symbol = symbol
};
<ControlTemplate
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="http://schemas.esri.com/arcgis/client/2009" > <Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected" />
<VisualState x:Name="Selected">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="MarkerSymbolCheckPointImg1">
<DiscreteObjectKeyFrame KeyTime="" Value="{x:Static Visibility.Hidden}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="MarkerSymbolCheckPointImg2">
<DiscreteObjectKeyFrame KeyTime="" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups> <Image Name="MarkerSymbolCheckPointImg1" Source="/ServerShell;component/Source/Image/point_checkpoint.png" Visibility="Visible" Width="" Height=""/>
<Image Name="MarkerSymbolCheckPointImg2" Source="/ServerShell;component/Source/Image/point_checkpoint_hit.png" Visibility="Hidden" Width="" Height=""/>
</Grid> </ControlTemplate>
其实采用上面的两种方式都是差不多的,都能够将相应的图片添加到相应地图层上面去,另外通过读取xml的这种方式能够通过代码的方式去控制添加图片的宽度和高度,这个也是非常好的一种方式,如果直接在前台进行代码的书写,那么在程序中将非常不好更改,这一点采用xml的方式会比较灵活的。
ArcGIS 中UniqueValueRenderer和SimpleRenderer的异同点的更多相关文章
- ArcGIS中的坐标系定义与转换 (转载)
原文:ArcGIS中的坐标系定义与转换 (转载) 1.基准面概念: GIS中的坐标系定义由基准面和地图投影两组参数确定,而基准面的定义则由特定椭球体及其对应的转换参数确定,因此欲正确定义GIS系统坐 ...
- ArcGIS中的坐标系统定义与投影转换【转】
ArcGIS中的坐标系统定义与投影转换 坐标系统是GIS数据重要的数学基础,用于表示地理要素.图像和观测结果的参照系统,坐标系统的定义能够保证地理数据在软件中正确的显示其位置.方向和距离,缺少坐标系统 ...
- arcgis中DEM如何生成等高线
地形图指比例尺大于1∶100万的着重表示地形的普通地图(根据经纬度进行分幅,常用有1:100万,1:50万,1比25万,1:15万,1:10万,1:5万等等).由于制图的区域范围比较小,因此能比较精确 ...
- 【转】+【举例】ArcGIS中的坐标系统定义与投影转换
背景知识: UTM (Universal Transverse Mercator)坐标系是由美国军方在1947提出的.虽然我们仍然将其看作与"高斯-克吕格"相似的坐标系统,但实际上 ...
- ArcGIS中的style样式的使用
MapGIS安装包大小(以M计算)与ArcGIS (以G计算)在数量级存在差异,就可以隐约知道ArcGIS功能的强大.ArcGIS更注重重用(比如符号库.模块等).数据与制图分离(尤其是制图表达最能体 ...
- ArcGIS中的北京54和西安80投影坐标系详解
ArcGIS中的北京54和西安80投影坐标系详解 1.首先理解地理坐标系(Geographic coordinate system),Geographic coordinate system直译为地理 ...
- ArcGIS中如何导出单个矢量要素图形
原文:ArcGIS中如何导出单个矢量要素图形 在ARCGIS中载入了一张含有省界的中国地图,是SHP文件.现在我只想要其中一块地区的,实现方法如下: 加入到ArcGIS后,右击图层,打开属性表(att ...
- ArcGIS中添加进自定义的ttf字符标记符号
原文:ArcGIS中添加进自定义的ttf字符标记符号 ArcGIS系统中的样式可能不能满足实际生产需要,为了实现快速制图,可自定义一些样式,以便重复利用. 1. 制作的符号库 使用 FontCre ...
- ArcGIS中利用ArcMap将地理坐标系转换成投影坐标系(从WKID=4326到WKID=102100)
原文:ArcGIS中利用ArcMap将地理坐标系转换成投影坐标系(从WKID=4326到WKID=102100) 对于非地理专业的开发人员,对与这些生涩的概念,我们不一定都要了解,但是我们要理解,凡是 ...
随机推荐
- [转]Oracle 清除incident和trace -- ADRCI用法
在oracle11g中,dump file的目录已经有所改变,bdump和udump整合到trace中,cdump独立出一个. E:\ora11g\app\Administrator\diag\rdb ...
- VsCode云端版本
VsCode的云端版与客户端简直是一模一样. 官网地址为:https://coder.com/ 安装命令: docker run -t -p 127.0.0.1:8443:8443 -v " ...
- Linux VNC安装
cat /etc/centos-release CentOS Linux release 7.4.1708 (Core) uname -r 3.10.0-693.el7.x86_64 VNC下载:ht ...
- Java多线程学习(一)---并发与多线程
Java并发与多线程 摘要: 1. 并发与并行的区别,何为并发编程,并发编程的优势在哪 2. 多线程.多任务.多进程机制概述 3. 多线程.多任务.多进程机制与编程思想的关系 一.并发 1.1 并发与 ...
- 单点登录SSO:图示和讲解
目录 概述 示例运行效果动画 跨域Web SSO时序图 代码截图 几个基本概念 涉及的站点和页面 重点理解:单点登录的核心步骤 敢说最准确的单点登录图示,因为: 我严格对照所画时序图的每个步骤,开发了 ...
- python3 urllib及requests基本使用
在python中,urllib是请求url连接的标准库,在python2中,分别有urllib和urllib,在python3中,整合成了一个,称谓urllib 1.urllib.request re ...
- 七、xadmin 编辑界面实现二级联动
很多时候,我们会遇到这种需求,通过一个select框中选择的值,去动态的加载另一个下拉框中的内容 对于前端的同学来讲,这个本应该是一个很简单的需求,获取第一个下拉框的值然后通过ajax去动态加载即可. ...
- Python_装饰器进阶_32
#带参数的装饰器 #500个函数 import time FLAGE = True def timmer_out(flag): def timmer(func): def inner(*args,** ...
- c++入门之 再话类
对于类,其结构并不难,但要理解其设计思想也并不容易,在此,我们可以通过下面的代码进一步理解和使用类: # ifndef VECTOR_H_ # define VECTOR_H_ # include & ...
- 提取PPT文件中的Vba ProjectStg Compressed Atom。Extract PPT VBA Compress Stream
http://msdn.microsoft.com/en-us/library/cc313106(v=office.12).aspx 微软文档 PartI ********************* ...