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; }