ArcGIS API for Silverlight 动态添加点的同时,添加文字说明(利用TextSymbol添加多文字信息 )
来源:互联网 发布:java基础的阶段的项目 编辑:程序博客网 时间:2024/05/16 01:40
在前面的博客中提到动态添加点,地址:http://blog.csdn.net/taomanman/article/details/7354103
这里根据需要,在添加点的同时,动态添加文字信息。
public void AddMarkerGraphics() { ESRI.ArcGIS.Client.Projection.WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator(); GraphicsLayer graphicsLayer = myMap.Layers["MyGraphicsLayer"] as GraphicsLayer; //添加点信息 Graphic graphic = new Graphic() { Geometry = mercator.FromGeographic(new MapPoint(115.257113, 33.0696150000001)), Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as Symbol }; graphicsLayer.Graphics.Add(graphic); //添加文字信息 TextSymbol textSymbol = new TextSymbol() { FontFamily = new System.Windows.Media.FontFamily("Microsoft YaHei"), Foreground = new System.Windows.Media.SolidColorBrush(Color.FromArgb(255, 117, 20, 99)), FontSize = 12, Text = "需要添加的文字,可以根据需要动态读取赋值" }; Graphic graphicText = new Graphic() { Geometry = mercator.FromGeographic(new MapPoint(115.257113, 33.0696150000001)), Symbol = textSymbol }; graphicsLayer.Graphics.Add(graphicText); }
主要是利用TextSymbol类来作为文字的显示,然后添加到Graphics中去。
如果需要在动态添加图标记的同时,添加多个文字注视的话,比如在点的上方添加数值,点的下方添加名称,这样的话,我们可以调整的有TextSymbol的OffsetX和OffsetY属性,进行相应的调整即可达到实现目的。
#region 水位/雨量 数值TextSymbol textSymbol2 = 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.YL24.ToString(), OffsetX = 6, OffsetY = 20}; Graphic graphicText2 = 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 = textSymbol2 }; graphicText.Attributes["TextYL"] = item.YL24; graphicsLayer.Graphics.Add(graphicText2); #endregion
实际的效果如下图,并且随着地图的缩放,这些文字也是随着更改,不会出现位置偏差
- ArcGIS API for Silverlight 动态添加点的同时,添加文字说明(利用TextSymbol添加多文字信息 )
- ArcGIS API for Silverlight 动态添加点的同时,添加文字说明(利用TextSymbol添加多文字信息 )
- ArcGIS API for Silverlight 添加图标(自定义图标)
- ArcGIS API for Silverlight 通过经纬度添加图标
- ArcGIS API for Silverlight 之ElementLayer使用及TextSymbol的模板使用
- ArcGIS API for Silverlight 之ElementLayer使用及TextSymbol的模板使用
- arcgis Silverlight添加箭头
- arcgis api for js中使用d3.js标注点的属性值代替textsymbol方式
- ArcGIS For JavaScript API 添加一个dynamic Service(动态服务)————(一)
- ArcGIS API for JS 添加地图控件
- 扩展ArcGIS API for Silverlight/WPF 中的TextSymbol支持角度标注
- 使用Visifire+ArcGIS API for Silverlight实现Graphic信息的动态图表显示
- 动态添加文字
- 代码动态添加文字
- ArcGIS教程:利用TIN工具添加点、线、面
- arcgis添加经纬度矢量点
- ArcGIS API for JS 添加图层列表控件
- ArcGis For Silverlight API,地图显示Gis,绘制点,线,绘制图等(二)--Silverlight 配置动态的 webService、动态加载ArcGis地图服务
- SQL优化34条
- 写出10个随机不同的数
- fedora 16 bash快捷键
- 2009微软亚洲技术中心面试题
- 黑马程序员_字符流的缓冲区
- ArcGIS API for Silverlight 动态添加点的同时,添加文字说明(利用TextSymbol添加多文字信息 )
- 【编程珠玑】第十章 节省空间
- Minix文件系统框架
- CMarkup 操作 和 CListCtrl
- SOA 和webservice 的区别
- 翻书效果原理
- 项目管理中的放弃艺术
- C语言 const 指针使用技巧之——返回指针的函数
- linux 锁类型