[Users] Displaying single legend items when the layer is a group layer comprised of several layers
Andrew Stewart
Andrew.Stewart at reddeer.ca
Fri Nov 19 00:22:20 CET 2010
Ok I did it in a different spot after my TreePanel was actually rendered and it works, was able to expand the node and uncheck a childnode then collapse it, although I'm not sure if this is the best way to do this.
-----Original Message-----
From: users-bounces at geoext.org [mailto:users-bounces at geoext.org] On Behalf Of Andrew Stewart
Sent: November 18, 2010 4:11 PM
To: users at geoext.org
Subject: Re: [Users] Displaying single legend items when the layer is a group layer comprised of several layers
I am having a slight issue with the LayerNode setup. Unfortunately I need to have some layers not displayed during load of the map, but using the below code all layers are automatically checked. When I try the code layerList_Base.expand(); so that I can uncheck one of the child nodes I get the following error -
Message: 'insertAdjacentHTML' is null or not an object
Line: 7
Char: 5686
Code: 0
URI: ext-3.3.0/ext-all.js
Is there a better way for me to uncheck one of these layers or something I can do to correct this error? I just need to be able to make a few of these layers not displayed so they are unchecked during load.. Appreciate any help!
// Base Group Layers
var layer_Base = new OpenLayers.Layer.WMS("Base", "http://localhost/WebService/Request.aspx",
{
layers: ['Rural_Lot_Line', 'Rural_Block_Line', 'Section_Lines', 'Linear_Parks', 'School_Sites', 'Recreation_Sites', 'Neighbourhood_Parks', 'Major_Parks', 'Neighbourhood_Boundary', 'Neighbourhood_Area__clear_', 'Hydrology', 'City_Boundary', 'Street_Secondary_Segment', 'Street_Segment', 'Arterial', 'Highway', 'Rural_Highway', 'Bridge'],
VERSION: "1.1.1",
format: 'image/png',
transparent: true
},
{ isBaseLayer: false,
singleTile: true,
buffer: 4
}
);
layerList_Base = new GeoExt.tree.LayerNode({
"layer": layer_Base,
"isLeaf": false,
"checked": false,
"cls": "rootnode",
"nodeType": "gx_layer",
"loader": {
"param": "LAYERS"
}
});
-----Original Message-----
From: users-bounces at geoext.org [mailto:users-bounces at geoext.org] On Behalf Of Andrew Stewart
Sent: November 18, 2010 2:39 PM
To: 'Andreas Hocevar'
Cc: users at geoext.org
Subject: Re: [Users] Displaying single legend items when the layer is a group layer comprised of several layers
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.]
_______________________________________________
Users mailing list
Users at geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users
[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.]
_______________________________________________
Users mailing list
Users at geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users
[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