1

I have a geodatabase with an annotation feature class in it containing 3 subtypes. Now I load the featuredataset to the map with this code:

IFeatureClass featClass = (workspace as IFeatureWorkspace).OpenFeatureClass(sNameOfFeatclass);
IFeatureLayer fLyr = new FeatureLayer();
fLyr.FeatureClass = featClass;    

In ArcMap the opened Layer is displayed but symbology is like polygon classified with the subtypes. In debug mode I see that the featureclass is of type esriFTAnnotation and the subtypes are present but the layer does not support the interface IAnnotationLayer.

In resources I only have found how to create an AnnotationFeature Class, but in my case the featureclass exists. How can I load it to map so that in layer properties the tab Annotation is displayed and not Labeling?

0

The problem is that annotation feature classes have two geometries: Shape and Element.. the Shape is the polygon, which you get if you open as an IFeatureLayer, but to access the Element as text you need to open as an IAnnotationLayer using IAnnotationLayerFactory.OpenAnnotationLayer:

IAnnotationLayerFactory pAnnoFact = new FDOGraphicsLayerFactoryClass();
IAnnotationLayer fLyr = pAnnoFact.OpenAnnotationLayer(
    (workspace as IFeatureWorkspace), 
    null, 
    sNameOfFeatclass);
    // parameter Feature Dataset is null because it's not in one.

then add the layer to your map like:

ArcMap.Document.FocusMap.AddLayer(fLyr as ILayer);
  • Thanks a lot, don't know why i din't found the command. So it works: if (featClass.FeatureType == esriFeatureType.esriFTAnnotation) { IAnnotationLayerFactory pAnnoFact = new FDOGraphicsLayerFactoryClass(); IAnnotationLayer aLyr = pAnnoFact .OpenAnnotationLayer(workspace as IFeatureWorkspace, featClass.FeatureDataset, sNameOfFeatclass); } – Ms. Smith Sep 17 '15 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.