唯一值渲染器: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的异同点的更多相关文章

  1. ArcGIS中的坐标系定义与转换 (转载)

    原文:ArcGIS中的坐标系定义与转换 (转载) 1.基准面概念:  GIS中的坐标系定义由基准面和地图投影两组参数确定,而基准面的定义则由特定椭球体及其对应的转换参数确定,因此欲正确定义GIS系统坐 ...

  2. ArcGIS中的坐标系统定义与投影转换【转】

    ArcGIS中的坐标系统定义与投影转换 坐标系统是GIS数据重要的数学基础,用于表示地理要素.图像和观测结果的参照系统,坐标系统的定义能够保证地理数据在软件中正确的显示其位置.方向和距离,缺少坐标系统 ...

  3. arcgis中DEM如何生成等高线

    地形图指比例尺大于1∶100万的着重表示地形的普通地图(根据经纬度进行分幅,常用有1:100万,1:50万,1比25万,1:15万,1:10万,1:5万等等).由于制图的区域范围比较小,因此能比较精确 ...

  4. 【转】+【举例】ArcGIS中的坐标系统定义与投影转换

    背景知识: UTM (Universal Transverse Mercator)坐标系是由美国军方在1947提出的.虽然我们仍然将其看作与"高斯-克吕格"相似的坐标系统,但实际上 ...

  5. ArcGIS中的style样式的使用

    MapGIS安装包大小(以M计算)与ArcGIS (以G计算)在数量级存在差异,就可以隐约知道ArcGIS功能的强大.ArcGIS更注重重用(比如符号库.模块等).数据与制图分离(尤其是制图表达最能体 ...

  6. ArcGIS中的北京54和西安80投影坐标系详解

    ArcGIS中的北京54和西安80投影坐标系详解 1.首先理解地理坐标系(Geographic coordinate system),Geographic coordinate system直译为地理 ...

  7. ArcGIS中如何导出单个矢量要素图形

    原文:ArcGIS中如何导出单个矢量要素图形 在ARCGIS中载入了一张含有省界的中国地图,是SHP文件.现在我只想要其中一块地区的,实现方法如下: 加入到ArcGIS后,右击图层,打开属性表(att ...

  8. ArcGIS中添加进自定义的ttf字符标记符号

    原文:ArcGIS中添加进自定义的ttf字符标记符号 ArcGIS系统中的样式可能不能满足实际生产需要,为了实现快速制图,可自定义一些样式,以便重复利用. 1.   制作的符号库 使用 FontCre ...

  9. ArcGIS中利用ArcMap将地理坐标系转换成投影坐标系(从WKID=4326到WKID=102100)

    原文:ArcGIS中利用ArcMap将地理坐标系转换成投影坐标系(从WKID=4326到WKID=102100) 对于非地理专业的开发人员,对与这些生涩的概念,我们不一定都要了解,但是我们要理解,凡是 ...

随机推荐

  1. 实战Performance Monitor监测EnyimMemcached

    首先要将EnyimMemcached安装至Windows Performance Counters中. 将Enyim.Caching.dll复制到一个文件夹中 在命令行中进入.NET Framewor ...

  2. SpringBoot系列 - 集成JWT实现接口权限认证

    会飞的污熊 2018-01-22 16173 阅读 spring jwt springboot RESTful API认证方式 一般来讲,对于RESTful API都会有认证(Authenticati ...

  3. spring boot 注解方式 idea报could not autowire

    File-Project Structure 页面 Facets下删掉 Spring(直接右键Delete) 这个解答是对的.并不会降低安全性!!因为创建项目的时候,都是先创建空项目再创建web mo ...

  4. node访问oracledb的环境搭建

    关于安装oracleDB环境官网说明地址: https://oracle.github.io/node-oracledb/INSTALL.html 环境搭建所需软件和文档的压缩包 链接: https: ...

  5. emqtt在centos6下的安装

    1 emqtt下载地址 http://www.emqtt.com/downloads 右键 复制链接 http://www.emqtt.com/downloads/3011/centos6 2 打开服 ...

  6. RabbitMQ用户增删及权限控制

    RabbitMQ用户增删及权限控制 用户角色分类 none:无法登录控制台 不能访问 management plugin,通常就是普通的生产者和消费者. management:普通管理者. 仅可登陆管 ...

  7. go struct{}的几种特殊用法

    参考:https://blog.csdn.net/kturing/article/details/80557280 1.声明为声明为map[string]struct{} 由于struct{}是空,不 ...

  8. Collection 和 Collections 、 Array 与 Arrays 的区别

    比较 Collection 和 Collections 的区别, Array 与 Arrays 的区别 Collection 和 Collections的区别 Collection 在 Java.ut ...

  9. AI 积分图

    积分图(Integral Image),可以用于快速计算矩形特征.积分图每个位置(x, y)的值,等于原图对应位置的左上角所有像素点的值之和.因为“积分”在离散情况下就是求和,所以这也是积分图的命名由 ...

  10. 【mongoDB查询进阶】聚合管道(二) -- 阶段操作符

    https://segmentfault.com/a/1190000010826809 什么是管道操作符(Aggregation Pipeline Operators) mongoDB有4类操作符用于 ...