ArcEngine标注显示比率
Public void showAnnotationByScale(IFeatureLayer pFeaturelayer)
{
IGeoFeatureLayer pGeoFeatureLayer=pFeaturelayer as IGeoFeatureLayer ;
//创建标注集接口,可以对标注进行添加、删除、查询、排序等操作
IAnnotateLayerPropertiesCollection pAnnotateLayerPropertiesCollection = new AnnotateLayerPropertiesCollectionClass();
pAnnotateLayerPropertiesCollection = pGeoFeatureLayer.AnnotationProperties;
pAnnotateLayerPropertiesCollection.Clear();
//创建标注的颜色
IRgbColor pRgbColor = new RgbColorClass();
pRgbColor.Red = 255;
pRgbColor.Green=0;
pRgbColor.Blue = 0;
//创建标注的字体样式
ITextSymbol pTextSymbol = new TextSymbolClass();
pTextSymbol.Color = pRgbColor;
pTextSymbol.Size = 12;
pTextSymbol.Font.Name = "宋体";
//定义 ILineLabelPosition接口,用来管理line features的标注属性,指定标注和线要素的位置关系
ILineLabelPosition pLineLabelPosition = new LineLabelPositionClass();
pLineLabelPosition.Parallel = false;
pLineLabelPosition.Perpendicular = true;
pLineLabelPosition.InLine = true;
//定义 ILineLabelPlacementPriorities接口用来控制标注冲突
ILineLabelPlacementPriorities pLineLabelPlacementPriorities = new LineLabelPlacementPrioritiesClass();
pLineLabelPlacementPriorities.AboveStart = 5;
pLineLabelPlacementPriorities.BelowAfter = 4;
//定义 IBasicOverposterLayerProperties 接口实现 LineLabelPosition 和 LineLabelPlacementPriorities对象的控制
IBasicOverposterLayerProperties pBasicOverposterLayerProperties = new BasicOverposterLayerPropertiesClass();
pBasicOverposterLayerProperties.LineLabelPlacementPriorities = pLineLabelPlacementPriorities;
pBasicOverposterLayerProperties.LineLabelPosition = pLineLabelPosition;
pBasicOverposterLayerProperties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon;
//创建标注对象
ILabelEngineLayerProperties pLabelEngineLayerProperties = new LabelEngineLayerPropertiesClass();
//设置标注符号
pLabelEngineLayerProperties.Symbol = pTextSymbol;
pLabelEngineLayerProperties.BasicOverposterLayerProperties = pBasicOverposterLayerProperties;
//声明标注的Expression是否为Simple
pLabelEngineLayerProperties.IsExpressionSimple = true;
//设置标注字段
pLabelEngineLayerProperties.Expression = "[DIQU]";
//定义IAnnotateLayerTransformationProperties 接口用来控制feature layer的display of dynamic labels
IAnnotateLayerTransformationProperties pAnnotateLayerTransformationProperties = pLabelEngineLayerProperties as IAnnotateLayerTransformationProperties ;
//设置标注参考比例尺
pAnnotateLayerTransformationProperties.ReferenceScale = 500000;
//定义IAnnotateLayerProperties接口,决定FeatureLayer动态标注信息
IAnnotateLayerProperties pAnnotateLayerProperties = pLabelEngineLayerProperties as IAnnotateLayerProperties ;
//设置显示标注最大比例尺
pAnnotateLayerProperties.AnnotationMaximumScale = 500000;
//设置显示标注的最小比例
pAnnotateLayerProperties.AnnotationMinimumScale = 25000000;
//决定要标注的要素
pAnnotateLayerProperties.WhereClause = "DIQU<>'宿州市'";
//将创建好的标注对象添加到标注集对象中
pAnnotateLayerPropertiesCollection.Add(pAnnotateLayerProperties);
//声明标注是否显示
pGeoFeatureLayer.DisplayAnnotation = true;
//刷新视图
this.axMapControl1.Refresh();
}
转载自:https://blog.csdn.net/wujianyouhun/article/details/52942466