ArcGIS API for Silverlight 之ElementLayer使用及TextSymbol的模板使用
原文:ArcGIS API for Silverlight 之ElementLayer使用及TextSymbol的模板使用
在开发中动态在地图上添加文字信息,可以使用TextSymbol添加文字
//动态添加文本
TextSymbol textSymbol = new TextSymbol()
{
FontFamily = new System.Windows.Media.FontFamily("Microsoft YaHei"),
Foreground = new System.Windows.Media.SolidColorBrush(Color.FromArgb(255, 255, 0, 0)),
FontSize = 14,
Text = item.ZDMC,
OffsetX = 12,
OffsetY = -5
}; Graphic graphicText1 = new Graphic()
{
Geometry = mercator.FromGeographic(new MapPoint(double.Parse(item.Latitute.ToString().Trim(), System.Globalization.CultureInfo.InvariantCulture), double.Parse(item.Longitute.ToString().Trim(), System.Globalization.CultureInfo.InvariantCulture))),
Symbol = textSymbol
}; graphicText1.Attributes["TextYLZMC"] = item.ZDMC;
graphicsLayer1.Graphics.Add(graphicText1);
如果要考虑给文字加背景颜色的话,该类就无法起作用了
//动态添加带背景颜色的文字信息
Border b = new Border();
b.Background = new SolidColorBrush(Colors.Blue);
b.Height = 20;
b.CornerRadius = new CornerRadius(5);
TextBlock tb = new TextBlock();
tb.Text = item.ZDMC;
tb.Foreground = new SolidColorBrush(Colors.White);
tb.HorizontalAlignment = HorizontalAlignment.Center;
tb.FontSize = 15;
b.Child = tb; ElementLayer.SetEnvelope(b, new Envelope(new MapPoint(double.Parse(item.Latitute.ToString().Trim(), System.Globalization.CultureInfo.InvariantCulture), double.Parse(item.Longitute.ToString().Trim(), System.Globalization.CultureInfo.InvariantCulture))),new MapPoint(double.Parse(item.Latitute.ToString().Trim(), System.Globalization.CultureInfo.InvariantCulture), double.Parse(item.Longitute.ToString().Trim(), System.Globalization.CultureInfo.InvariantCulture))));
elementLayer.Children.Add(b);
效果如下
提供第二种方法,使用TextSymbol的模板使用:
<esri:TextSymbol x:Key="SWZTextSymbol">
<esri:TextSymbol.ControlTemplate>
<ControlTemplate>
<Border Background="White" BorderBrush="Black" CornerRadius="5" BorderThickness="1,1,1,1">
<TextBlock
Width="70"
FontSize="14"
Text="{Binding Attributes[TextSWZMC]}" //注意这里的TextSWZMC,和后台代码中要一致
Foreground="Blue"
FontFamily="Microsoft YaHei"
HorizontalAlignment="Center" />
</Border>
</ControlTemplate>
</esri:TextSymbol.ControlTemplate>
</esri:TextSymbol>
TextSymbol textSymbol = LayoutRoot.Resources["SWZTextSymbol"] as TextSymbol; //这里和模板的Key名称要一致
textSymbol.OffsetX = 15;
textSymbol.OffsetY = -15; Graphic graphicText = new Graphic()
{
Geometry = mercator.FromGeographic(new MapPoint(double.Parse(item.Latitute.ToString().Trim(), System.Globalization.CultureInfo.InvariantCulture), double.Parse(item.Longitute.ToString().Trim(), System.Globalization.CultureInfo.InvariantCulture))),
Symbol = textSymbol
};
graphicText.Attributes["TextSWZMC"] = item.ZDMC; //注意这里的TextSWZMC,和前台xaml代码中要一致
graphicsLayer11.Graphics.Add(graphicText);
ArcGIS API for Silverlight 之ElementLayer使用及TextSymbol的模板使用的更多相关文章
- 扩展ArcGIS API for Silverlight/WPF 中的TextSymbol支持角度标注
原文 http://blog.csdn.net/esricd/article/details/7587136 在ArcGIS API for Silverlight/WPF中原版的TextSymbol ...
- ArcGIS API for Silverlight 绘制降雨路径动画
原文:ArcGIS API for Silverlight 绘制降雨路径动画 #region 降雨动画演示 2014-04-16 List<Graphic> graphics = new ...
- ArcGIS API for Silverlight开发入门
你用上3G手机了吗?你可能会说,我就是喜欢用nokia1100,ABCDEFG跟我 都没关系.但你不能否认3G是一种趋势,最终我们每个人都会被包裹在3G网络中.1100也不是一成不变,没准哪天为了打击 ...
- 使用ArcGIS API for Silverlight + Visifire绘制地图统计图
原文:使用ArcGIS API for Silverlight + Visifire绘制地图统计图 最近把很久之前做的统计图又拿出来重新做了一遍,感觉很多时候不复习,不记录就真的忘了,时间是最好的稀释 ...
- 使用Visifire+ArcGIS API for Silverlight实现Graphic信息的动态图表显示
原文:使用Visifire+ArcGIS API for Silverlight实现Graphic信息的动态图表显示 首先来看一看实现的效果: PS:原始的程序中更新曲线数据时添加了过渡的效果,具体可 ...
- arcgis api for silverlight开发系列之二:缓存图层与动态图层及图层总结 .
本文摘自:http://blog.csdn.net/leesmn/article/details/6916458(很优秀的博客) 作为ESRI的平台的一份子arcgis api for silve ...
- ArcGIS api fo silverlight学习一(silverlight加载GeoServer发布的WMS地图)
最好的学习资料ArcGIS api fo silverlight官网:http://help.arcgis.com/en/webapi/silverlight/samples/start.htm 一. ...
- ArcGIS API for Silverlight动态标绘的实现
原文:ArcGIS API for Silverlight动态标绘的实现 1.下载2个dll文件,分别是: ArcGISPlotSilverlightAPI.dll 和 Matrix.dll 其下载地 ...
- ArcGIS API for Silverlight地图加载众多点时,使用Clusterer解决重叠问题
原文:ArcGIS API for Silverlight地图加载众多点时,使用Clusterer解决重叠问题 问题:如果在地图上加载成百上千工程点时,会密密麻麻,外观不是很好看,怎么破? 解决方法: ...
随机推荐
- 金子上的友情[XDU1011]
Problem 1011 - 金子上的友情 Time Limit: 1000MS Memory Limit: 65536KB Difficulty: Total Submit: 336 Ac ...
- COJ979 WZJ的数据结构(负二十一)
试题描述 请你实现一个数据结构,完成这样的功能: 给你一个N个点的图,初始状态无边. 每次加入一条双向边(u,v,w),若加入后没有构成一棵生成树,输出“Not Yet”,否则输出当前最小生成树的权值 ...
- float塌陷有关问题
程序代码需要用到的CSS样式body{ margin:0px; padding:0px; text-align:center; font:Arial, Helvetica, sans-serif; f ...
- The Stable Marriage Problem
经典稳定婚姻问题 “稳定婚姻问题(The Stable Marriage Problem)”大致说的就是100个GG和100个MM按照自己的喜欢程度给所有异性打分排序.每个帅哥都凭自己好恶给每个MM打 ...
- java 中文转换成Unicode编码和Unicode编码转换成中文
转自:一叶飘舟 http://blog.csdn.net/jdsjlzx/article/details/ package lia.meetlucene; import java.io.IOExcep ...
- 戴尔PowerEdge服务器命名规则和型号分类
从第十代服务器开始,戴尔重新规范了服务器的名字,以现在的第十二代主流PowerEdge R620服务器为例: 第一位是字母,R代表机架式服务器,其它有: R:Rack,机架式服务器 T:Tower,塔 ...
- ITIL图示
- JQuery文件上传插件uploadify在MVC中Session丢失的解决方案
<script type="text/javascript"> var auth = "@(Request.Cookies[FormsAuthenticati ...
- Uncaught RangeError: Maximum call stack size exceeded解决思路
今天突然碰到这样的JavaScript错误:Uncaught RangeError: Maximum call stack size exceeded 这个翻译过来就是堆栈溢出了. 1.原因:有小类到 ...
- win7锁定到任务栏的路径在哪里
You can find pinned apps in: %AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar ...