唯一值渲染器: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. DataGrid获取单元格的值

    string str = (dataGrid.Columns[0].GetCellContent(dataGrid.Items[0]) as TextBlock).Text;

  2. 最长回文(manacher模板)

    #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> us ...

  3. Python:Day19 正则表达式补充

    贪婪匹配 贪婪匹配是指字符后面是*+?的时候,都是尽可能多的匹配,如果不想尽可能多的匹配,那么在这三个字符后面加?号即可,这样变成惰性匹配,按最少匹配. ret = re.findall('ab??' ...

  4. How to get Pycharm

    PyCharm是一种Python IDE,带有一整套可以帮助用户在使用Python语言开发时提高其效率的工具,比如:代码跳转.智能提示.自动完成.单元测试.版本控制.此外,该IDE提供了一些高级功能, ...

  5. Home Assistant-自动化设备

    触发器(trigger) 条件(condition) 动作(action) 自动化中的模板(template) 触发器(trigger) 时间(time)触发器时间触发器在指定的时间触发规则,可以是某 ...

  6. DNS原理-HTTP原理-TCP原理

    第一章:企业DNS原理 相信大家都知道windows和linux的hosts文件是:IP地址和域名的对应关系,我们一般访问网站的步骤: 打开网页-----输入网址-------查看本地的DNS库是否存 ...

  7. mybatis之一对多

    今天主要话题围绕这么几个方面? mybatis一对多示例 sql优化策略 一.mybatis之一对多 在说一对多之前,顺便说一下一对一. 一对一,常见的例子,比如以常见的班级例子来说,一个班主任只属于 ...

  8. git pull 解决 refusing to merge unrelated histories 错误

    解决办法: 1.cmd进入项目的根目录. 2.执行下面的命令:git pull origin master --allow-unrelated-histories.可以提交成功. 3.再次push.

  9. vscode快捷键大全

    一般Ctrl + Shift + P,F1显示命令调色板 Ctrl + P快速打开,转到文件...Ctrl + Shift + N新窗口/实例 Ctrl + Shift + W关闭窗口/实例 Ctrl ...

  10. .Net业务搭配实用技术栈

    前言 昨天有篇文章在讨论webform的设计思路,我已经四五年不用webform了,虽然它也提供了HttpModule和httphandle来处理请求,提供了一般处理程序ashx来简化处理流程,但依然 ...