阅读:1298回复:0
MapXtreme 2005学习(4):添加标注图层
<br>在<font face="Verdana">MapXtreme 2005</font>中添加标注图层是非常容易的,只要知道要标准的表和相关的列,几行代码就搞定了,比想像中要容易多了。当然还有一些标注样式可以设置,可以从类库中查到相关的说明。</p>
<p><font face="Verdana"> /// <summary><br> /// 添加标注图层<br> /// Design by Glacier<br> /// 2008年8月6日<br> /// <param name="tableName">标注的表名</param><br> /// <param name="columnName">标注的列名</param><br> /// </summary><br> public static void ShowLabelLayer(string tableName, string columnName)<br> {<br> MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias];<br> <br> //新建标注图层<br> LabelLayer labelLayer = new LabelLayer();<br> myMap.Layers.Add(labelLayer);</font></p> <p><font face="Verdana"> //指定要标注的数据表<br> LabelSource labelSource = new LabelSource(MapInfo.Engine.Session.Current.Catalog.GetTable(tableName);<br> labelLayer.Sources.Append(labelSource);<br> <br> //指定要标准字段所在的列<br> labelSource.DefaultLabelProperties.Caption = columnName;</font></p> <p><font face="Verdana"> //标注样式等属性<br> //source.DefaultLabelProperties.Visibility.Enabled = true;<br> //source.DefaultLabelProperties.Visibility.VisibleRangeEnabled = true;<br> //source.DefaultLabelProperties.Visibility.VisibleRange = new VisibleRange(0.01, 10, MapInfo.Geometry.DistanceUnit.Mile);<br> //source.DefaultLabelProperties.Visibility.AllowDuplicates = true;<br> //source.DefaultLabelProperties.Visibility.AllowOverlap = true;<br> //source.DefaultLabelProperties.Visibility.AllowOutOfView = true;<br> //source.Maximum = 50;<br> //source.DefaultLabelProperties.Layout.UseRelativeOrientation = true;<br> //source.DefaultLabelProperties.Layout.RelativeOrientation = MapInfo.Text.RelativeOrientation.FollowPath;<br> //source.DefaultLabelProperties.Layout.Angle = 33.0;<br> //source.DefaultLabelProperties.Priority.Major = "index";<br> //source.DefaultLabelProperties.Layout.Offset = 7;<br> //source.DefaultLabelProperties.Layout.Alignment = MapInfo.Text.Alignment.BottomRight;<br> //Font font = new Font("黑体", 10);<br> //font.ForeColor = System.Drawing.Color.DarkBlue;<br> //source.DefaultLabelProperties.Style.Font = font;<br> }</font></p> |
|
|