要素的标注

要素的标注标注有两种方法,一个是添加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)

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值