要素的标注标注有两种方法,一个是添加TextElement到文档对象,另一种是基于要素的某个属性进行标注,它需要载入数据支持。第一种方法在P8中可以看到。下面介绍后一种方法:
Public sub Anno(byval pGeoFeatLyr as iGeofeaturelayer,byval field as string)
Dim pGeoFeatLayer As IGeoFeatureLayer
pGeoFeatLayer = pGeoFeatLyr
Dim pAnnoProps As IannotateLayerPropertiesCollection
pAnnoProps = pGeoFeatLyr.AnnotationProperties
pAnnoProps.Clear() 必须执行这个语句,否则里面会默认有一个pAnnoLayerProps
Dim pAnnoLayerProps As IAnnotateLayerProperties
Dim pPosition As ILineLabelPosition
Dim pPlacement As ILineLabelPlacementPriorities
Dim pBasic As IBasicOverposterLayerProperties
Dim pLabelEngine As ILabelEngineLayerProperties
Dim pTextSyl As ItextSymbol 标注的文字格式,注意
pTextSyl = New TextSymbol
Dim pFont As stdole.StdFont
pFont = New stdole.StdFont
pFont.Name = "verdana"
pFont.Size = 5
pTextSyl.Font = pFont
pTextSyl.Color = HSVColor(250, 160, 200)
pPosition = New LineLabelPosition
pPosition.Parallel = False
pPosition.Perpendicular = True
pPlacement = New LineLabelPlacementPriorities
pBasic = New BasicOverposterLayerProperties
pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline
pBasic.LineLabelPlacementPriorities = pPlacement
pBasic.LineLabelPosition = pPosition
pLabelEngine = New LabelEngineLayerProperties
pLabelEngine.Symbol = pTextSyl
pLabelEngine.BasicOverposterLayerProperties = pBasic
pLabelEngine.Expression = field field必须是这个样子——"[STATE_NAME]"
pAnnoLayerProps = pLabelEngine
pAnnoProps.Add(pAnnoLayerProps)
pGeoFeatLyr.DisplayAnnotation = True
AxMapControl.CtlRefresh(esriViewDrawPhase.esriViewBackground)
End sub
消除标注的方法也很简单,由于pGeoFeatLyr是一个全局变量,我们只要设置如下代码即可:
pGeoFeatLyr.DisplayAnnotation = False
AxMapControl.CtlRefresh(esriViewDrawPhase.esriViewBackground)
要素的标注
最新推荐文章于 2021-04-29 23:17:27 发布