I want to put some labels in globe control in order ot specify some positions. As we have "Label Features' option in ArcGlobe, I think to add a featurelayer with fields in globe control, then label it should be workable and this should be similar to map control. Then I use following code:
//add an featurelayer
IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory();
IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(@"D:\ARCGIS_SampleMaps\Data\USA", 0);
IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
IFeatureClass pFC = pFeatureWorkspace.OpenFeatureClass("USstates");
IFeatureLayer pFLayer = new FeatureLayerClass();
pFLayer.FeatureClass = pFC;
pFLayer.Name = pFC.AliasName;
ILayer pLayer = pFLayer as ILayer;
GlobeControl.Globe.AddLayerType(pLayer, esriGlobeLayerType.esriGlobeLayerTypeDraped, false);
//MapControl.AddLayer(pLayer);
mainGlobeMap.Refresh();
//labeling Feaatures
IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer;
IAnnotateLayerPropertiesCollection pAnnotateLayerPropertiesCollection = pGeoFeatureLayer.AnnotationProperties;
IAnnotateLayerProperties pAnnotateLayerProperties;
IElementCollection pElementCollection = new ElementCollectionClass();
IElementCollection puElementCollection = new ElementCollectionClass();
ILabelEngineLayerProperties pLabelEngineLayerProperties;
pAnnotateLayerPropertiesCollection.QueryItem(0, out pAnnotateLayerProperties, out pElementCollection, out puElementCollection);
pLabelEngineLayerProperties = pAnnotateLayerProperties as ILabelEngineLayerProperties;
pLabelEngineLayerProperties.Expression = "[" + "STATE_NAME" + "]";
pGeoFeatureLayer.DisplayAnnotation = true;
GlobeControl.Refresh();
This code works well in map control, but fails in globe control: featurelayer is added in without any labels shown. Do I miss something? Could someone show me some examples? THX.. 🙂 P.S: Are there ways to add advanced labels like billboarded labels in [URL="http://blogs.esri.com/esri/arcgis/2011/01/18/labeling-in-arcglobe/http://"]?