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解决重叠问题 问题:如果在地图上加载成百上千工程点时,会密密麻麻,外观不是很好看,怎么破? 解决方法: ...
随机推荐
- protected(C# 参考)
protected 关键字是一个成员访问修饰符.受保护成员在它的类中可访问并且可由派生类访问.有关 protected 与其他访问修饰符的比较,请参见可访问性级别. 仅当访问通过派生类类型发生时,基类 ...
- ural 1150. Page Numbers
1150. Page Numbers Time limit: 1.0 secondMemory limit: 64 MB John Smith has decided to number the pa ...
- BZOJ 1067 & Interval_Tree
1067: [SCOI2007]降雨量 Time Limit: 1 Sec Memory Limit: 162 MB Submit: 3099 Solved: 800 Description 我们常常 ...
- asp.net 微信企业号办公系统-流程设计--流程步骤设置-按钮设置
按钮设置是配置当前步骤的处理者可以执行哪些操作,每个按钮都有对应的执行脚本(javascript脚本). 从左边的按钮列表中选择当前步骤需要的按钮. 注意:如果是流程最后一步则要配置完成按钮而不是发送 ...
- 关于EnumerateObjectsUsingBlock和for-in之间的较量
遍历一个数组看谁快 参赛选手 ForLoop, For - in, enumerateObjectsUsingBlock这个三个方法: NSMutableArray *test = [NSMuta ...
- 8.0 Qweb 报表编写步骤
8.0 采用的是Qweb报表,摒弃了7.0中的RML报表. 1.首先在xml文件中注册一个报表: <report id="qweb_test_report" model=&q ...
- mysql 动态sql语句
; SET @ss = ' INSERT INTO prod_attr SELECT ? AS prod_id,A.* FROM ( SELECT 1 AS attr_id,\'中国出版社\' AS ...
- POJ 2892 Tunnel Warfare(线段树单点更新区间合并)
Tunnel Warfare Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 7876 Accepted: 3259 D ...
- linux下挂在u盘,移动硬盘的方法,转移服务器资料的时候,使用移动硬盘什么最方便了
本文章是在centos环境下操作的 最近linux服务器我不小心吧root下面的用户配置,不能远程登录,而且我对linux系统配置也不熟悉,最后的办法就是去了一趟机房,还好是在深圳南山科技园,不算太远 ...
- 【转】TCP协议中的三次握手和四次挥手(图解)
http://blog.csdn.net/whuslei/article/details/6667471