AE设置标注
基本过程如下,但是需要注意的是labelEngine的Expression属性:依据某字段标注时,一定要加上中括号,即“[属性字段名称]”

1 private void Annotation(IGeoFeatureLayer pGeoFeatLyr, string annoField, ITextSymbol textSyl, bool disLabel) 2 { 3 try 4 { 5 IAnnotateLayerPropertiesCollection pAnnoProps = pGeoFeatLyr.AnnotationProperties; 6 pAnnoProps.Clear(); 7 IAnnotateLayerProperties pAnnoLayerProps = null; 8 ILineLabelPosition pPosition = null; 9 ILineLabelPlacementPriorities pPlacement = null; 10 IBasicOverposterLayerProperties pBasic = null; 11 ILabelEngineLayerProperties pLabelEngine = null; 12 13 pPosition = new LineLabelPosition(); 14 pPosition.Parallel = false; 15 pPosition.Perpendicular = true; 16 pPlacement = new LineLabelPlacementPriorities(); 17 pBasic = new BasicOverposterLayerProperties(); 18 pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline; 19 pBasic.LineLabelPlacementPriorities = pPlacement; 20 pBasic.LineLabelPosition = pPosition; 21 pLabelEngine = new LabelEngineLayerProperties() as ILabelEngineLayerProperties; 22 pLabelEngine.Symbol = textSyl; 23 pLabelEngine.BasicOverposterLayerProperties = pBasic; 24 25 pLabelEngine.Expression = String.Format("[{0}]", annoField); 26 pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties; 27 pAnnoProps.Add(pAnnoLayerProps); 28 if (disLabel) 29 pGeoFeatLyr.DisplayAnnotation = true; 30 else 31 pGeoFeatLyr.DisplayAnnotation = false; 32 33 m_hook.MapControl.Refresh(esriViewDrawPhase.esriViewBackground, null, null); 34 } 35 catch 36 { } 37 }