AE+vb开发,标注没有显示,请教是怎么回事?
Private Sub Form_Load()'首先添加你本地的图层文件,我的放在D:\Shapfile下
' Dim i As IAoInitialize
' Set i = New AoInitialize
' i.Initialize (esriLicenseProductCodeEngine)
Me.MapControl1.AddShapeFile "D:\代码整理\data\Shapefile", "分市州"
'Me.MapControl1.AddShapeFile "D:\Shapfile", "县界"
Me.TOCControl1.SetBuddyControl Me.MapControl1
Dim pGeoFeatLayer As IGeoFeatureLayer
'标注集接口
Dim pAnnoPropCollection As IAnnotateLayerPropertiesCollection
'IAnnotateLayerProperties接口可以操作标注的显示比例尺,Sql过滤等
Dim pAnnoProps As IAnnotateLayerProperties
'IAnnotateLayerTransformationProperties接口可以控制标注的参考比
'例尺,Units,标注边界,缩放比率。
Dim pAnnoLyrTransProps As IAnnotateLayerTransformationProperties
'ILineLabelPosition接口用来控制标注和要素的相对位置和关系
Dim pPosition As ILineLabelPosition
'ILineLabelPlacementPriorities用来控制标注冲突
Dim pPlacementPriorities As ILineLabelPlacementPriorities
'IBasicOverposterLayerProperties接口实现对LineLabelPosition对象、
'LineLabelPlacementPriorities对象及一写高级属性的控制
Dim pBasicOverposterLayerProperties As IBasicOverposterLayerProperties
'ILabelEngineLayerProperties是标注渲染的最终描述对象,由
'IAnnotateLayerPropertiesCollection交给GeoFeatureLayer进行标注渲染
Dim pLabelEngine As ILabelEngineLayerProperties
Dim pColor As IColor
Dim pFont As IFontDisp
Dim pTxtSymbol As ITextSymbol
Set pGeoFeatLayer = Me.MapControl1.Layer(0)
Set pAnnoPropCollection = pGeoFeatLayer.AnnotationProperties
'清除默认的标注设置
pAnnoPropCollection.Clear
'创建颜色
Set pColor = New RgbColor
pColor.RGB = RGB(255, 0, 0)
'创建字体
Set pFont = New StdFont
With pFont
.Name = "宋体"
'.Bold = True
End With
'创建体样式来标注图层
Set pTxtSymbol = New TextSymbol
With pTxtSymbol
.Color = pColor
.Font = pFont
.Size = 12
End With
'创建BasicOverposterLayerProperties对象实例
Set pPosition = New LineLabelPosition
With pPosition
.Parallel = False '示例:修改标注的属性
.Perpendicular = True
.InLine = True
End With
Set pPlacementPriorities = New LineLabelPlacementPriorities
With pPlacementPriorities
.AboveStart = 5 '示例:让Above和Start的标注优先级为5
.BelowAfter = 4 '示例:让Below和After的标注优先级为4,低于AboveStart
End With
Set pBasicOverposterLayerProperties = New BasicOverposterLayerProperties
'把创建的pPosition和pPlacementPriorities附给
'pBasicOverposterLayerProperties
With pBasicOverposterLayerProperties
.FeatureType = esriOverposterPolygon
.LineLabelPlacementPriorities = pPlacementPriorities
.LineLabelPosition = pPosition
End With
'创建标注对象
Set pLabelEngine = New LabelEngineLayerProperties
With pLabelEngine
Set .Symbol = pTxtSymbol
Set .BasicOverposterLayerProperties = pBasicOverposterLayerProperties
'使用简单表达式
.IsExpressionSimple = True
.Expression = "[名称]" '设置被标注的字段,关于Expression的语法见[注释1]
''.Expression = "[名称] & "",面积:"" & [SHAPE_area] & "" 万平方公里"""
'.Expression = "[名称] & [SHAPE_area] "
End With
Set pAnnoLyrTransProps = pLabelEngine
With pAnnoLyrTransProps
.ReferenceScale = 2500000 '设置标注的参考比例尺
End With
Set pAnnoProps = pLabelEngine
With pAnnoProps
'设置标注可见的最大、最小比例尺
.AnnotationMaximumScale = 2500000
.AnnotationMinimumScale = 25000000
''.WhereClause = "名称 <> '陕西'" '不显示陕西这个标注
End With
'把创建好的标注对象添加到标注集对象
pAnnoPropCollection.Add pAnnoProps
'显示标注
pGeoFeatLayer.DisplayAnnotation = True
Me.MapControl1.Refresh
End Sub
补充:企业软件 , 地理信息系统