唯一值渲染器: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. [matlab] 17.网格矩阵

    生成网格矩阵,并且根据条件筛选,重新赋值为0,1二值图像 clear all;close all; %生成二值图 index= randperm(2500,1000); %生成10个不重复随机指标 Z ...

  2. (predicted == labels).sum().item()作用

    ⚠️(predicted == labels).sum().item()作用,举个小例子介绍: # -*- coding: utf-8 -*-import torch import numpy as ...

  3. B+Tree原理及mysql的索引分析

    一.索引的本质 MySQL官方对索引的定义为:索引(Index)是帮助MySQL高效获取数据的数据结构.提取句子主干,就可以得到索引的本质:索引是数据结构. 我们知道,数据库查询是数据库的最主要功能之 ...

  4. C# 多线程及同步简介示例

           60年代,在OS中能拥有资源和独立运行的基本单位是进程,然而随着计算机技术的发展,进程出现了很多弊端,一是由于进程是资源拥有者,创建.撤消与切换存在较大的时空开销,因此需要引入轻型进程: ...

  5. BZOJ 5467 Slay the Spire

    BZOJ 5467 Slay the Spire 我的概率基础也太差了.jpg 大概就是这样,因为强化牌至少翻倍,所以打出的牌必定是全部的强化牌或者$k-1$个强化牌,然后剩余的机会打出最大的几个攻击 ...

  6. 史上最全面的Spring Boot Cache使用与整合

    一:Spring缓存抽象 Spring从3.1开始定义了org.springframework.cache.Cache和org.springframework.cache.CacheManager接口 ...

  7. CSS Grid 读书笔记

    基本概念 MDN上的解释是这样的 CSS Grid Layout excels at dividing a page into major regions or defining the relati ...

  8. 启发式合并 splay合并 线段树合并基础

    Gold is everywhen! - somebody 启发式合并 将小的集合一个个插入到大的集合. 每次新集合大小至少比小集合大一倍,因此每个元素最多合并\(\log n\)次,总复杂度为\(n ...

  9. JS 执行上下文

    先看个小例子 function fn(){ console.log(a);//undefined; var a = 1; } fn(); 为什么打印出来的是 undefined 呢? 执行上下文概念 ...

  10. 软件工程(FZU2015) 赛季得分榜,第七回合

    SE_FZU目录:1 2 3 4 5 6 7 8 9 10 11 12 13 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分=团队得分+个人贡献分 个人贡献分: 个人 ...