cpmikey21

ArcGIS Engine .NET add labels to a layer.

Discussion created by cpmikey21 on Jul 29, 2010
I have a .NET engine application where I would like to show labels on a layer.  I am not sure if labels is the correct term, perhaps annotations?  Something which will show some information on the map such as a name for a feature.  After searching for a couple of days now, I have only found out how to show the MapTips, not something which will show all of the time.

What I currently have is the following which doesn't work.  Any ideas which piece I am missing?

        Dim objLblEngineLyrProps As ILabelEngineLayerProperties
        Dim objAnnoLyrPropsColl As IAnnotateLayerPropertiesCollection
        Dim objAnnoLyrProps As IAnnotateLayerProperties
        Dim objRGBColor As IRgbColor

        Dim obj As IGeoFeatureLayer
        'obj.DisplayFiel()
        'objAnnoLyrProps = New LabelEngineLayerProperties
        objRGBColor = New RgbColor
        objRGBColor.Red = 0
        objRGBColor.Green = 0
        objRGBColor.Blue = 128
        objLblEngineLyrProps = New LabelEngineLayerProperties
        objLblEngineLyrProps.Expression = "STATE_NAME"
        objLblEngineLyrProps.Symbol.Color = objRGBColor
        objLblEngineLyrProps.Symbol.Size = 20.0
        objAnnoLyrProps = TryCast(objLblEngineLyrProps, IAnnotateLayerProperties)
        objAnnoLyrProps.LabelWhichFeatures = esriLabelWhichFeatures.esriVisibleFeatures
        'objAnnoLyrPropsColl = objGeoFeatureLayer.AnnotationProperties
        'objAnnoLyrPropsColl.Clear()
        'objAnnoLyrPropsColl.Add(objAnnoLyrProps)
        'objGeoFeatureLayer.AnnotationProperties = objAnnoLyrPropsColl
        objGeoFeatureLayer.AnnotationProperties.Clear()
        objGeoFeatureLayer.AnnotationProperties.Add(objAnnoLyrProps)
        objGeoFeatureLayer.DisplayAnnotation = True
        objAnnoLyrProps.DisplayAnnotation = True
        AxMapControl1.ActiveView.Refresh()

Outcomes