添加标注图层

在MapXtreme 2005中添加标注图层是非常容易的,只要知道要标准的表和相关的列,几行代码就搞定了,比想像中要容易多了。当然还有一些标注样式可以设置,可以从类库中查到相关的说明。
复制内容到剪贴板
代码:
/// <summary>

/// 添加标注图层

/// 2008年8月6日

/// <param name="tableName">标注的表名</param>

/// <param name="columnName">标注的列名</param>

/// </summary>

public static void ShowLabelLayer(string tableName, string columnName)

{

MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias];


//新建标注图层

LabelLayer labelLayer = new LabelLayer();

myMap.Layers.Add(labelLayer);

//指定要标注的数据表

LabelSource labelSource = new LabelSource(MapInfo.Engine.Session.Current.Catalog.GetTable(tableName);

labelLayer.Sources.Append(labelSource);


//指定要标准字段所在的列

labelSource.DefaultLabelProperties.Caption = columnName;

//标注样式等属性

//source.DefaultLabelProperties.Visibility.Enabled = true;

//source.DefaultLabelProperties.Visibility.VisibleRangeEnabled = true;

//source.DefaultLabelProperties.Visibility.VisibleRange = new
VisibleRange(0.01, 10, MapInfo.Geometry.DistanceUnit.Mile);

//source.DefaultLabelProperties.Visibility.AllowDuplicates = true;

//source.DefaultLabelProperties.Visibility.AllowOverlap = true;

//source.DefaultLabelProperties.Visibility.AllowOutOfView = true;

//source.Maximum = 50;

//source.DefaultLabelProperties.Layout.UseRelativeOrientation = true;

//source.DefaultLabelProperties.Layout.RelativeOrientation = MapInfo.Text.RelativeOrientation.FollowPath;

//source.DefaultLabelProperties.Layout.Angle = 33.0;

//source.DefaultLabelProperties.Priority.Major = "index";

//source.DefaultLabelProperties.Layout.Offset = 7;

//source.DefaultLabelProperties.Layout.Alignment = MapInfo.Text.Alignment.BottomRight;

//Font font = new Font("黑体", 10);

//font.ForeColor = System.Drawing.Color.DarkBlue;

//source.DefaultLabelProperties.Style.Font = font;

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值