Select to view content in your preferred language

ArcGIS Desktop / RasterLayer Hide Subelements VBA

592
2
05-31-2010 02:32 AM
HendrikPischel
Emerging Contributor
Hello,
i add a RasterLayer to a Group Layer witch is expanded. But the RasterLayer itself is expland too. (I can see the Symbology definition.)
Is there any way to hide the Symbology definition?

    Set pRasterLayer = New RasterLayer
    pRasterLayer.CreateFromDataset pRasterDataset
    pGroupLayer.Add pRasterLayer
    pGroupLayer.Expanded = True 'This is the Grouplayer witch should be expanded.


Regrads, Hendrik
0 Kudos
2 Replies
HendrikPischel
Emerging Contributor
Hi there,

i didn't find any way to hide the symbologie.
Im sure that this is nessesary for many other Layer types.

Doesn't someone know how to do?

Regrads, Hendrik
0 Kudos
HendrikPischel
Emerging Contributor
Hello,
i found a way to do this using the ILegendGroup. There wars a post about it in the old Forums.

    
    Dim pGroupLayer As IGroupLayer
    Dim pRasterLayer As IRasterLayer
    Dim pWsFact As IWorkspaceFactory
    Dim pWS As IRasterWorkspace
    Dim pRasterDataset As IRasterDataset
    Dim pLegInfo As ILegendInfo
    Dim pLegGroup As ILegendGroup
    Dim pMxDocument As IMxDocument
    Dim pMap As IMap
    
    Set pMxDocument = ThisDocument
    Set pMap = pMxDocument.FocusMap
 
    ' pLayer is the groupLayer where the RasterLayer should be added to
    Set pGroupLayer = pLayer
    
    ' Open raster dataset in a workspace
    ' set up a workspace factory to open a workspace (a folder) where the Picture is stored
    Set pWsFact = New RasterWorkspaceFactory
    Set pWS = pWsFact.OpenFromFile(gbl_Rasterdaten_Pfad, 0)
    Set pRasterDataset = pWS.OpenRasterDataset(FileName & ".tif")

    Set pWsFact = Nothing
    Set pWS = Nothing

    ' Add Layer to TOC
    Set pRasterLayer = New RasterLayer
    pRasterLayer.CreateFromDataset pRasterDataset
    pGroupLayer.Add pRasterLayer
    pGroupLayer.Expanded = True
    
    ' Hide Symbologie
    Set pLegInfo = pRasterLayer
    Set pLegGroup = pLegInfo.LegendGroup(0)
    pLegGroup.Visible = False       'set to False to contract.

    pMxDocument.ActiveView.Refresh
    pMxDocument.UpdateContents


Regards, Hendrik
0 Kudos