[Users] Displaying single legend items when the layer is a group layer comprised of several layers

Andrew Stewart Andrew.Stewart at reddeer.ca
Thu Nov 18 22:09:13 CET 2010


Is this possible to display each individual item so I can still check/uncheck them using my below code, or can I use a different GeoExt/Ext container to accomplish this? I need to keep the layers grouped because of performance but I still need to be able to display each individual layer so that I can turn them on/off. Is this possible? Any example/help immensely appreciated.


My layer group is declared as the following -

     // Base Group Layers
                  var layer_Base = new OpenLayers.Layer.WMS("Base Layers", "http://localhost/WebService/Request.aspx",
                    {
                        layers: ['Bridge,Rural_Highway,Highway,Arterial,Street_Segment, Street_Secondary_Segment, City_Boundary,                        Hydrology,Neighbourhood_Area__clear_,Neighbourhood_Boundary,Major_Parks,Neighbourhood_Parks,Recreation_Sites,School_Sites,Linear_Parks,Section_Lines,Rural_Block_Line,Rural_Lot_Line'],
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false,
                      singleTile: true,
                      buffer: 4
                    }
                );


Then I define my Treenode root and treepanel, and create a GeoExt LayerContainer to load the layer into the root node. Can the layers above be displayed as individual items with separate checkboxes somehow?

 var layerRoot_Legend = new Ext.tree.TreeNode({
        enableDD: true,
        text: "All Legend Items",
        loaded: true,
        expanded: true
        });

        var layerTree_Legend = new Ext.tree.TreePanel({
        title: '',
        root: layerRoot_Legend,
        enableDD: true,
        applyLoader: true,
        rootVisible: false
        });


//Base layerList
        layerList_Base = new GeoExt.tree.LayerContainer({
        text: 'Base',
        layerStore: mapPanel.layers,
        leaf: false,
        enableDD: true,
        cls: 'rootnode',
        singleClickExpand: true,
        expanded: false,
        checked: false,
        listeners: {
    'checkchange' :  function(node, checked)
    {
        // If a parent node is unchecked, uncheck all the children
        if (node.getUI().isChecked()) {
            node.expand();
            node.eachChild(function(child){
              child.ui.toggleCheck(true);
            });
        }
        if (!node.getUI().isChecked())
        {
            node.expand();
            node.eachChild(function(child) {
                child.ui.toggleCheck(false);
            });
        }
    }
  },
        loader:
        {
            filter: function(record)
            {
              if (record.data.title == 'Base Layers')
                    return true;
            }
            }
        });


 layerRoot_Legend.appendChild(layerList_Base);









-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20101118/1a2012a9/attachment-0001.htm 


More information about the Users mailing list