supermap 在地图上显示 属性信息(添加图层)
来源:互联网 发布:cassandra java 编辑:程序博客网 时间:2024/05/29 16:43
主要的类:
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() { } }}
- supermap 在地图上显示 属性信息(添加图层)
- supermap objects 地图上添加 点线面图层 和删除图层 的类
- superMAP超图控制TiledDynamicRESTLayer地图图层显示与隐蔽
- ArcGIS For Android 在地图上显示属性图形信息和属性文本信息
- 在google地图上显示一个层
- supermap学习系列(七)——用户自己在地图上添加点、线、面标注
- 读取本地XML文件信息,在地图上添加标注,显示当前位置详细地理信息
- 地图(创建, 添加图块, 图层, 对象层,添加图块属性调整修改地图)
- ArcGIS for iOS地图上添加测距功能,及显示相应的路径图层
- 在腾讯地图上添加公众号门店的标注信息
- 地图图层添加
- Android高德地图,添加Marker会遮挡小蓝点,只需设置一个属性,可以让小蓝点显示在Marker上
- python爬虫租房信息在地图上显示
- 划过地图进行地图属性信息显示
- (笔记)在地图上添加大头针
- supermap iclient for javascript开发中: 图层属性整理
- 百度地图(让我显示在地图上)
- ArcGIS Engine + C# 开发过程中,鼠标在地图上滑过时,显示地图相关信息
- Endless icon: 每天都更新的图标集
- 请求头和响应头
- SetWindowPos详解
- Android_python_push(2)
- ACM的入门书籍及方法
- supermap 在地图上显示 属性信息(添加图层)
- 激活灰显按钮
- 关于Android中ANR的一些思考
- cookie的介绍,创建cookie
- 什么叫长尾关键词
- 开发文本编辑器学习笔记
- vc封装dll类的简单方法
- 淘宝卖家过劳死VS富士康跳楼死
- Android获取版本号