-
if (axMapControl1.LayerCount > 0)
-
{
-
IGeoFeatureLayer pGeoFeatureLayer;
-
ILineLabelPosition pLineLabelPosition;
-
ILabelEngineLayerProperties pLabelEngineLayerProperties;
-
IAnnotateLayerProperties pAnnotateLayerProperties;
-
-
pGeoFeatureLayer = (IGeoFeatureLayer)axMapControl1.get_Layer(0);
-
pGeoFeatureLayer.AnnotationProperties.Clear();
-
-
pLineLabelPosition = new LineLabelPosition();
-
pLineLabelPosition.Above = false;
-
pLineLabelPosition.AtEnd = false;
-
pLineLabelPosition.Below = false;
-
pLineLabelPosition.Horizontal = false;
-
pLineLabelPosition.InLine = true;
-
pLineLabelPosition.OnTop = true;
-
pLineLabelPosition.Parallel = true;
-
pLineLabelPosition.ProduceCurvedLabels = true;
-
-
ITextSymbol pTextSymbol = new TextSymbol();
-
IColor pColor = new RgbColor();
-
pColor.RGB = 255;
-
pTextSymbol.Size = 8;
-
pTextSymbol.Font.Name = "宋体";
-
pTextSymbol.Color = pColor;
-
-
pLabelEngineLayerProperties = new LabelEngineLayerProperties() as ILabelEngineLayerProperties;
-
pLabelEngineLayerProperties.Symbol = pTextSymbol;
-
pLabelEngineLayerProperties.IsExpressionSimple = true;
-
pLabelEngineLayerProperties.Expression = "[NAME]";//需要中括号,这里显示NAME字段属性
-
pLabelEngineLayerProperties.BasicOverposterLayerProperties.LineLabelPosition = pLineLabelPosition;
-
-
pAnnotateLayerProperties = (IAnnotateLayerProperties)pLabelEngineLayerProperties;
-
pAnnotateLayerProperties.DisplayAnnotation = true;
-
pAnnotateLayerProperties.FeatureLayer = pGeoFeatureLayer;
-
-
pAnnotateLayerProperties.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures;
-
pAnnotateLayerProperties.WhereClause = "";
-
-
pGeoFeatureLayer.AnnotationProperties.Add(pAnnotateLayerProperties);
-
pGeoFeatureLayer.DisplayAnnotation = true;
-
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
-
}
参考来源:http://blog.csdn.net/suinon/article/details/5705421
阅读(3922) | 评论(0) | 转发(0) |