[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:39:13 CET 2010


Thank you very much! I was looking at this before and could not get it to work.. But your provided example code was exactly enough to get me going.. The problem I was doing before was when defining my layers I wasn't seperating them by 'layer name', 'layer name' .. I had them all individually inside only one 'layer name, layer name' but when I put quotes around each one and seperated them by comma it works perfectly, thanks again!


-----Original Message-----
From: Andreas Hocevar [mailto:ahocevar at opengeo.org] 
Sent: November 18, 2010 2:26 PM
To: Andrew Stewart
Cc: users at geoext.org
Subject: Re: [Users] Displaying single legend items when the layer is a group layer comprised of several layers

Hi,

you may want to have a look at http://geoext.org/lib/GeoExt/widgets/tree/LayerParamLoader.html.

For your layer_Base layer, the tree node configuration could look like this:

layerList_Base = new GeoExt.tree.LayerNode({
    "layer": layer_Base,
    "isLeaf": false,
    "loader": {
        "param": "LAYERS"
    }
});

Regards,
Andreas.

On Nov 18, 2010, at 22:09 , Andrew Stewart wrote:

> 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);
>  
>  
>  
>  
>  
>  
> 
> This e-mail is intended for the original recipient(s) only. If you have received it in error, please advise the sender and delete this message.
> 
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users

-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



[This message has been scanned for security content threats and viruses.]

[The City of Red Deer I.T. Services asks that you please consider the environment before printing this e-mail.]






More information about the Users mailing list