MapInfo添加文字标签效果的代码
2016-09-01 08:43:03 访问(1393) 赞(0) 踩(0)
/// <summary>
/// label数据源,显示地图
/// </summary>
public void labelShow()
{
Catalog Cat
=
MapInfo.Engine.Session.Current.Catalog;
Table table = Cat.GetTable("Point_temp");
FeatureLayer featureLayer = new FeatureLayer(table);
this.mapControl1.Map.Layers.Add(featureLayer);
LabelLayer labelLayer = new LabelLayer();
this.mapControl1.Map.Layers.Insert(0, labelLayer);
LabelSource source = new LabelSource(table);
source.DefaultLabelProperties.Caption = "CarNo";
source.DefaultLabelProperties.Layout.Offset = 12;
source.DefaultLabelProperties.Visibility.VisibleRangeEnabled = true;
source.DefaultLabelProperties.Visibility.VisibleRange = new VisibleRange(0, 1, MapInfo.Geometry.DistanceUnit.Kilometer);
MapInfo.Data.SearchInfo info = MapInfo.Data.SearchInfoFactory.SearchWhere("CarNo='民航C70123'");
info.QueryDefinition.AppendColumns("CarNo");
Feature nyState = Session.Current.Catalog.SearchForFeature(table, info);
LabelProperties properties = new LabelProperties();
properties.Attributes = LabelAttribute.VisibilityEnabled | LabelAttribute.Caption | LabelAttribute.Style;
properties.Visibility.Enabled = true;
properties.Caption = "CarNo";
properties.Style.Font.ForeColor = Color.Blue;
properties.Style.Font.Size = 9;
SelectionLabelModifier modifier = new SelectionLabelModifier();
modifier.Properties.Add(nyState.Key, properties);
source.Modifiers.Append(modifier);
labelLayer.Sources.Append(source);
}
标签:
MapInfo添加文字标签效果的代码 


上一条:
下一条:
相关评论
发表评论