您的位置:首页 > 编程语言 > C#

MapXtreme+C#添加标注

2009-04-15 10:57 204 查看
public static void ShowLabelLayer(string tableName, string columnName)
{
MapInfo.Mapping.Map map = MapInfo.Engine.Session.Current.MapFactory[0];
//新建标注图层
LabelLayer labelLayer = new LabelLayer();
map.Layers.Add(labelLayer);
//指定要标注的数据表
LabelSource labelSource = new LabelSource(MapInfo.Engine.Session.Current.Catalog.GetTable((tableName)));
labelLayer.Sources.Append(labelSource);
//指定要标注字段所在的列
labelSource.DefaultLabelProperties.Caption = columnName;
//标注样式等属性
labelSource.DefaultLabelProperties.Visibility.Enabled = true;
labelSource.DefaultLabelProperties.Visibility.VisibleRangeEnabled = true;
labelSource.DefaultLabelProperties.Visibility.VisibleRange = new VisibleRange(0.01, 10, MapInfo.Geometry.DistanceUnit.Mile);
labelSource.DefaultLabelProperties.Visibility.AllowDuplicates = true;
labelSource.DefaultLabelProperties.Visibility.AllowOutOfView = true;
labelSource.DefaultLabelProperties.Visibility.AllowOverlap = true;
labelSource.Maximum = 50;
labelSource.DefaultLabelProperties.Layout.UseRelativeOrientation = true;
labelSource.DefaultLabelProperties.Layout.RelativeOrientation = MapInfo.Text.RelativeOrientation.FollowPath;
labelSource.DefaultLabelProperties.Layout.Angle = 33.0;
labelSource.DefaultLabelProperties.Priority.Major = "index";
labelSource.DefaultLabelProperties.Layout.Offset = 7;//偏移量
labelSource.DefaultLabelProperties.Style.Font.TextEffect = MapInfo.Styles.TextEffect.Box;//标注背景,BOX为方框
labelSource.DefaultLabelProperties.Layout.Alignment = MapInfo.Text.Alignment.BottomRight;
Font font = new Font("黑体", 10);
font.ForeColor = System.Drawing.Color.DarkBlue;
labelSource.DefaultLabelProperties.Style.Font = font;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: