[Users] layer tree configuration question

Ralph Dell RDell at CatawbaCountyNC.gov
Tue Mar 30 17:18:13 CEST 2010


This is what I have decided on for now. The following json gives me a
check box for my layer, followed by icons and text for the different
types of features in the layer. I would not say it is a good solution to
apply to multiple layers but my layer tree is pretty short and I am only
need to symbolize one layer this way.

My Schools layer is a group layer containing my Schools, and a dummy
layer that contains one point that is never displayed. 

checked:  is assigned a NULL value

 

                 },{

                nodeType: "gx_layer",                  // pretty much
what I want, starts with a  check box and label followed by icons and
labels

                layer: 'Schools',

                param: "LAYERS",

                item: "catawba2:schools",

                text: 'Schools',

                iconCls: 'cc_empty',

                leaf: true,

                expanded: true,

                children: [{

                  nodeType: "gx_layer",

                  layer: 'Schools',

                  param: "LAYERS",

                  item: "catawba2:dummy",

                  text: 'Elementary Schools',

                  iconCls: 'cc_elem_pt',

                  checked: null2,

                  leaf: true

                  },{

                  .

                  .

                  .

                }]

                 },{          

 

Ralph Dell, GISP

GIS Dept.

Catawba County, NC

 

From: Matt Priour [mailto:mpriour at kestrelcomputer.com] 
Sent: Friday, March 26, 2010 3:29 PM
To: Ralph Dell; users at geoext.org
Subject: Re: [Users] layer tree configuration question

 

I can tell you from a lot of trial & error, that the 'children' property
of any gx_layerXXX nodetype are not evaluated. BaselayerContainer,
OverlaylayerContainer, ParamLayer all use loaders to populate their
child node arrays. The best you can do with either of these 3 node types
is to set a 'baseParams' property which will need get applied as part of
the node config for each of the child nodes created by the loader.

 

If you use gx_layer as the nodetype, then the childnodes do get
evaluated. However, it also expects to find a layer property on the node
and a matching layer in the layer store. If either of these conditions
aren't met, errors will occur and your tree won't render or work
correctly.

 

You have a few options:

1. Be highly specific for the layer nodes you want to customize. Use
'async' & 'gx_layer' node types with the specific layer & attributes you
wish to represent. You can use a 'gx_layer' node type as a group layer
container node, but it must also have a matching layer in the layer
store (I've never tried a dummy layer here but it might also work).

 

2. Use the 'gx_layerparam' or 'gx_overlaylayercontainer' node to create
the tree and then modify the node ui after creation. In other words,
write a function to find the layer you are interested in, access the
associated node, access the node's nodeUI and change properties there
(such as the iconCls, etc...)

 

3. I have created a custom node type (gx_complexlayer) that has similar
node construction logic as the 'gx_layer' node type but doesn't expect a
layer property and expects it's descendant nodes (at some level) to have
a layer property. This was useful to me as it can contain both gx_layer
nodes and other loader based nodes as well as using a loader itself if
configured to do so. I've made a ticket for this functionality but not
submitted a patch yet, because I 'haven't written test or an example for
this node type yet and it will fail in some corner cases. I have
attached it as a patch here if you want to use it with the understanding
that it is certainly incomplete.

 

Matt Priour

Kestrel Computer Consulting

 

From: Ralph Dell <mailto:RDell at CatawbaCountyNC.gov>  

Sent: Friday, March 26, 2010 1:32 PM

To: users at geoext.org 

Subject: [Users] layer tree configuration question

 

Thanks to the examples and previous forum posts I almost have my layer
tree looking exactly as I would like.

 

What I haven't been able to figure out is under  a layer check box, (in
this case Schools), I would like to display icons and text that would
correspond to  map symbology for different types of features in the
given layer.  I do not get anything displayed under the check box and
have been unsuccessful  in finding a solution.

 Any pointers or examples on how to accomplish that would be
appreciated.

 

I am pulling my layers from a group layer similar to Tasmania ( Group
Layer) in the Tree Nodes example.

 

Here is my json:

 

var treeConfig = new OpenLayers.Format.JSON().write([

  {

   nodeType: "gx_baselayercontainer",

  layer: 'Layers',

  isLeaf : false,

 loader: {

       param: "LAYERS"

  }

  },{

  text: 'School Layers',

  expanded: true,

  children: [{

   nodeType: "gx_layerparam",

   layer: 'Schools',

  param: "LAYERS",

  item: "catawba2:schools",

  text: 'Schools',

  expanded: true,

  children: [{                                                        //
under the Schools check box I want to display symbols and text that
correspond

     text: 'Elementary Schools',                     // to the symbology
that I use on the map

    IconCls: 'cc_elem'                                        // nothing
displays

    },{
// how can I add symbols and text here?

    text: 'Middle School Districts3',              // I don't even know
if using children: [{}] is the correct approach.

    iconCls: 'cc_middle'

     }]

},{

nodeType: "gx_layerparam",

layer: 'Schools',

param: "LAYERS",

item: "catawba2:elementary_school_districts",

text: 'Elementary School Districts',

iconCls: 'cc_elem_line',

}]

 }], true);

 

________________________________

_______________________________________________
Users mailing list
Users at geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20100330/55e7fdf9/attachment.htm 


More information about the Users mailing list