Proble with globecontro and grouplayer

507
4
06-25-2012 04:33 AM
New Contributor
hi,

I'm using the object globecontrol and I ran into problems adding featurelayer (drapped) within group layers.

1) if I add the featurelayer, not inside group layers, works perfectly
2) if I add a grouplayer, with a first featurelayer associated, it works perfectly
3) If a grouplayer, with featurelayer associated, already present on globe I try to add a second featurelayer is not represented, but is correctly added to the TOC in the grouplayer (but only by doing a refresh on the subject grouplayer)

My code:

m_GroupLayer ---> grouplayer (IgroupLayer)
pFLy --> featurelayer (IFeatureLayer)
m_objGlobeControl --> globecontrol

' ---------------------------------------------------------------------- First time Add FeatureLayer and GroupLayer, and Add GroupLayer to GLobe

m_GroupLayer.Add(pFLy)
m_objGlobeControl.Globe.AddLayerType(m_GroupLayer, esriGlobeLayerType.esriGlobeLayerTypeDraped, True)
TryCast(m_objGlobeControl.GlobeDisplay, IGlobeDisplayLayers).RefreshLayer(m_GroupLayer)

' ---------------------------------------------------------------------- Second time add other FeatureLayer to GroupLayer

m_GroupLayer.Add(pFLy)
TryCast(m_objGlobeControl.GlobeDisplay, IGlobeDisplayLayers).RefreshLayer(m_GroupLayer)





thanks

fabrizio
Reply
0 Kudos
4 Replies
New Contributor
anyone can help me?
Reply
0 Kudos
Occasional Contributor
IGlobe::AddLayerType really appears to be the only method that will properly initialize a feature layer for use with a Globe.  Adding an IFeatureLayer object directly to an existing IGroupLayer object does not initialize the feature layer object properly.

About your code:

My code:

m_GroupLayer ---> grouplayer (IgroupLayer)
pFLy --> featurelayer (IFeatureLayer)
m_objGlobeControl --> globecontrol

' ---------------------------------------------------------------------- First time Add FeatureLayer and GroupLayer, and Add GroupLayer to GLobe

'>> Here you add a feature layer to a group layer
m_GroupLayer.Add(pFLy)
'>> Here you add the group layer to the globe using IGlobe::AddLayer.  This initializes properly any feature layers in the group layer object being added.
m_objGlobeControl.Globe.AddLayerType(m_GroupLayer, esriGlobeLayerType.esriGlobeLayerTypeDraped, True)
TryCast(m_objGlobeControl.GlobeDisplay, IGlobeDisplayLayers).RefreshLayer(m_GroupLayer)

' ---------------------------------------------------------------------- Second time add other FeatureLayer to GroupLayer

'>> Here you add another feature layer but directly to the existing group layer of the globe, but this does not initialize the feature layer properly for use with globe.
'>> We can see this better if using similar program code in an ArcGlobe custom command or add-in button.  The feature layer that got added to the exiting group
'>> layer is missing all the Layer Properties tabs that are indicative of a draped, globe layer.  
m_GroupLayer.Add(pFLy)
TryCast(m_objGlobeControl.GlobeDisplay, IGlobeDisplayLayers).RefreshLayer(m_GroupLayer)

I would do one of the following workarounds:
1.  Reconstruct the group layer progammatically if you need to add more layers to an existing group layer > delete the existing group layer > and add the newly constructed group layer with all the sub layers inside of it which now includes the new layer you wanted to add, using the same code you used to add the group layer first:
m_objGlobeControl.Globe.AddLayerType(m_GroupLayer, esriGlobeLayerType.esriGlobeLayerTypeDraped, True)

or,

2.  Add the IFeatureLayer you want to add to the existing group layer directly to the globe using IGlobe::AddLayerType.  This will initialize the layer as a draped, globe layer so it can display properly, but the feature layer will not be in the group layer.  Programmatically "move" the newly added layer to the group layer as shown below.  Unfortunately, the MoveLayer() method of IMap and IScene which you can use with a Globe will not move a layer inside a group layer.  Also, the Globe object cannot be casted to IMapLayers in order to use IMapLayers.InsertLayerInGroup method so we cannot choose in which position within a group layer to insert a layer.  Only the Map and Scene object can be casted to IMapLayers .  With these shotcomings in mind, I only see the possibility of achieving the "move" by:

a.  Add a feature layer to the globe using IGlobe::AddLayerType, e.g.
axGlobeControl1.Globe.AddLayerType(pLayer, esriGlobeLayerType.esriGlobeLayerTypeDraped, true);
The layer displays/initialized correctly but is not inside the group layer
b.  Remove the same layer from the globe.  The pLayer object however still lives in memory so it can be still be referenced.
(axGlobeControl1.Globe as IScene).DeleteLayer(pLayer);
The layer has been removed from the globe
c.  Now add the layer to the group layer and refresh as you are already doing
m_GroupLayer.Add(pLayer);
(axGlobeControl1.GlobeDisplay as IGlobeDisplayLayers).RefreshLayer(m_GroupLayer);
Reply
0 Kudos
New Contributor
thanks Edgar, it's work fine.

ciao Fabrizio
Reply
0 Kudos
New Contributor
I apologize, I have found another problem (I implemented the suggested changes clearly):

1) I create GroupLayer-1
2) Into a GroupLayer-1 add FeatureLayer-1 (featureclass Polygon)
3) All OK
4) Into a GroupLayer-1 add FeatureLayer-2 (featureclass Point) represented by a marker
5) All Feature-1 disappear from the FeatureLayer GlobeControl (but not deleted)

A) The same thing happens if FeatureLayer-2 is created on another GroupLayer
B) It all works perfectly if FeatureLayer-1 and FeatureLayer-2 are featureclass Point represented by a marker
C) It all works perfectly if I don't use GroupLayer


thanks

fabrizio
Reply
0 Kudos