supermap 在地图上显示 属性信息(添加图层)
2012-11-06 11:48
176 查看
主要的类:
using System; using System.Collections.Generic; using System.Drawing; using System.Text; using SuperMap.Data; using SuperMap.Mapping; using SuperMap.UI; namespace showLayer { internal class SampleRun { private Workspace m_workspace; private MapControl m_mapControl; private Layer mylayer; private static readonly Double fontHeight = 0.4; public Boolean m_isWaitCursor { get { return m_mapControl.IsWaitCursorEnabled; } set { m_mapControl.IsWaitCursorEnabled = value; } } public SampleRun(Workspace workspace, MapControl mapcontrol) { this.m_workspace = workspace; this.m_mapControl = mapcontrol; this.m_mapControl.Map.Workspace = m_workspace; Initialize(); //加载地图方法 } /// <summary> /// 加载地图 /// </summary> private void Initialize() { WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(@"D:\souce\supermap\SampleData\World\World.smwu"); m_workspace.Open(conInfo); m_mapControl.Map.Open(m_workspace.Maps[0]); m_mapControl.Action = Action.Pan; m_mapControl.Map.ViewEntire(); AddCustomLayer(); EnableCustomCursor(); } /// <summary> /// 添加属性的一个图层 /// </summary> public void AddCustomLayer() { DatasetVector dataset = m_workspace.Datasources[0].Datasets["Capital"] as DatasetVector; ThemeLabel label = new ThemeLabel(); label.LabelExpression = "SMID"; label.IsOverlapAvoided = true; mylayer = m_mapControl.Map.Layers.Add(dataset, label, true); mylayer.ValueExpressions = new string[] { "Country", "Capital" }; mylayer.ElementDrawing += new ElementDrawingEventHandler(mylayer_ElementDrawing); m_mapControl.Map.Refresh(); } /// <summary> /// 元素绘制事件,可以根据其参数ElementDrawingEventArgs,获得坐标位置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mylayer_ElementDrawing(object sender, ElementDrawingEventArgs e) { GeoCompound compound = e.Element as GeoCompound; GeoPoint basePoint = e.Geometry as GeoPoint; String country = e.Values[0].ToString(); String capital = e.Values[1].ToString(); AddDisplayContent(compound, basePoint, country, capital); } private void AddDisplayContent(GeoCompound tagcompound, GeoPoint basepoint, String country, String capital) { GeoText geoTextTime = CreateTime(basepoint); tagcompound.AddPart(geoTextTime); GeoText geoTextCountry = CreateCountry(basepoint, country); tagcompound.AddPart(geoTextCountry); } /// <summary> /// 获得当前点的时间 /// </summary> /// <param name="basePoint">坐标点</param> /// <returns></returns> private static GeoText CreateTime(GeoPoint basePoint) { GeoText geoTime = null; //基准时间 DateTime baseTime = System.TimeZone.CurrentTimeZone.ToUniversalTime(System.DateTime.Now); //根据基准时间获得当地时间 DateTime localTime = baseTime.AddHours(Math.Round(basePoint.X / 15)); geoTime = new GeoText(new TextPart("Time:" + localTime.ToShortTimeString(), new Point2D(basePoint.X, basePoint.Y))); geoTime.TextStyle.Alignment = TextAlignment.TopLeft; geoTime.TextStyle.ForeColor = Color.Red; geoTime.TextStyle.FontHeight = fontHeight; geoTime.TextStyle.IsSizeFixed = false; return geoTime; } /// <summary> /// 获取国家名,并且显示在时间下面 /// </summary> /// <param name="basePoint"></param> /// <param name="country"></param> /// <returns></returns> private static GeoText CreateCountry(GeoPoint basePoint, String country) { GeoText geoCountry = new GeoText(new TextPart("Country:" + country, new Point2D(basePoint.X, basePoint.Y - fontHeight))); geoCountry.TextStyle.Alignment = TextAlignment.TopLeft; geoCountry.TextStyle.FontHeight = fontHeight; geoCountry.TextStyle.ForeColor = Color.Red; geoCountry.TextStyle.IsSizeFixed = false; return geoCountry; } public void RemoveCustomLayer() { } /// <summary> /// 添加鼠标靠近弹出框 /// </summary> public void EnableCustomCursor() { } /// <summary> /// 删除鼠标靠近弹出框 /// </summary> public void DisableCustomCursor() { } } }
相关文章推荐
- ArcEngine二次开发_02(鼠标移过图层中显示特定的属性信息)
- 地图(创建, 添加图块, 图层, 对象层,添加图块属性调整修改地图)
- 谷歌地图API 显示地图添加maker点,信息窗体及事件
- 读取本地XML文件信息,在地图上添加标注,显示当前位置详细地理信息
- superMAP超图控制TiledDynamicRESTLayer地图图层显示与隐蔽
- 将图层属性表的信息显示在DataGridView的控件上
- ArcGIS For Android 在地图上显示属性图形信息和属性文本信息
- 划过地图进行地图属性信息显示
- SuperMap超图——使用SQLite数据库中的点位信息创建数据源并在图层中显示数据
- 建立抽象类Student,添加属性学号,姓名,平均分,添加方法show()显示学生的个人信息(学号,姓名),添加抽象方法average()计算学生的平均成绩。建立Student的子类studentIT
- 在地图上点击一下,在图层上画一个点,并显示相关的信息
- ArcGis For Silverlight API,地图显示Gis,绘制点,线,绘制图等(三)--绘制点、线、圆,显示提示信息
- C#中怎样在Button控件上添加提示语,让鼠标经过按钮时显示提示信息!
- 富文本(TYAttributedLabel 简单,强大的属性文本控件(无需了解CoreText),支持图文混排显示,支持添加链接,image和UIView控件,支持自定义排版显示)
- Android地图显示泡泡信息问题
- 百度地图relase版本地图图层显示不出来
- ant table 添加双击展开扩展显示信息
- IIS 添加网站显示错误消息 “无更多可用的内存以更新安全信息” 解决方法
- Windows 7删除任务栏Shell_NotifyIcon添加过的垃圾图标显示配置信息
- ######纯注解ssh环境:crm系统实体类设计 ①客户信息的【数据字典】表的产生原因+②设计理解:【字典类没有添加客户属性的原因】=深刻理解类间关联,建立在有需求的基础上。