How to get the field name labeled in a layer?

969
1
04-26-2011 09:49 AM
ViridianaGO
New Contributor III
Hi everybody! Thanks for read my message. I want to get the field name that is labeled in a layer but I can not do this. Also, I want to get the color, font and size of the symbol that the label have. Can somebody help me please??? I really will appreciate your help.
0 Kudos
1 Reply
ViridianaGO
New Contributor III
Hi again! I have tried to do this (I do not know if it is correct to get the name field labeled):

//I get the item in the Collection
IAnnotateLayerPropertiesCollection pAnnoLayerPropsColl = pGeoFLayer.getAnnotationProperties();        
IAnnotateLayerProperties[] alpArray = new IAnnotateLayerProperties[10];
IElementCollection[] visibles = new IElementCollection[10];
IElementCollection[] invisibles = new IElementCollection[10];
pAnnoLayerPropsColl.queryItem(0, alpArray, visibles, invisibles);

//I get the text in the label
IElement[] pElement = new IElement[10];            
ITextElement pTextElement;
int i = 0;
String sText;
            
 for (i=0; i < visibles.length; i++){
             visibles[0].queryItem(i, pElement, null);
             pTextElement = (ITextElement) pElement[0];
             sText = pTextElement.getText();
             System.out.println(sText);
 }


I guess sText has the name field, but when I run this, this show me the AutomationException:

AutomationException: 0x80070057 - The hook has not yet been set into the CommandPool in 'esriControls.CommandPool.1'
at com.esri.arcgis.carto.ElementCollection.queryItem(Unknown Source)


in the line:
              visibles[0].queryItem(i, pElement, null);

I do not know what this mean, I really will appreciate your help, Thanks!
0 Kudos