[Users] Layer Tree groups

antoniofacno antoniofcano at gmail.com
Mon Nov 8 18:38:51 CET 2010


Hello,

Again, I'm reading all the examples I find but the question doesn't 
becomes to me so clear... sorry :(

I've got this Layer configuration (two groups: Base and Labores) and I'd 
like to show a layer tree panel. Following the 
http://api.geoext.org/1.0/examples/tree.js example, I'm able to show the 
carpets Base and Lavores 2010 but when expanding they do nothing.

My code is this it:

         var lindes = new OpenLayers.Layer.WMS(
             "Lindes",
             "http://getcloud.info:8080/geoserver/wms",
            {
                 layers: "lindes",
                 format: "image/png",
                 transparent:true
             },
             {isBaseLayer: true, singleTile: true}
         );

         var catastro = new OpenLayers.Layer.WMS(
             "Base",
             "http://getcloud.info:8080/geoserver/wms",
            {
                 layers: "ao:Catastro",
                 format: "image/png",
                 transparent:true
             },
             {isBaseLayer: true, singleTile: true}
         );

         var labores_2010 = new OpenLayers.Layer.WMS(
                 "Labores 2010",
                    "http://getcloud.info:8080/geoserver/wms",
                 {
                     layers: [
                         "tratamiento_2010",
                         "rulo_2010",
                         "varetas_2010",
                         "desbrozar_2010",
                         "soplar_2010"
                     ],
                     format: "image/png",
                     transparent:true
                 }, {
                     isBaseLayer: false,
                     buffer: 0,
                     // exclude this layer from layer container nodes
                     displayInLayerSwitcher: false,
                     visibility: false
                 }
            );

         layer = [catastro,lindes , labores_2010, labores];
         map.events.register('click', map, getAOFeatureInfo );

         //Panel Central con el Mapa
         var mapPanel = new GeoExt.MapPanel({
             map: map
         });

         var treeConfig = new OpenLayers.Format.JSON().write([{
             layer: "Base",
             nodeType: "gx_baselayercontainer",
         }, {
             nodeType: "gx_layer",
             //nodeType: "gx_overlaylayercontainer",
             layer: "Labores 2010",
             load: {
                 param: "LAYERS"
             }
         }], true);

         // create the tree with the configuration from above
         tree = new Ext.tree.TreePanel({
             border: true,
             region: "west",
             title: "Capas",
             width: 200,
             split: true,
             collapsible: true,
             //loader: new Ext.tree.TreeLoader(),
             root: {
                 nodeType: "async",
                 // the children property of an Ext.tree.AsyncTreeNode 
is used to
                 // provide an initial set of layer nodes. We use the 
treeConfig
                 // from above, that we created with 
OpenLayers.Format.JSON.write.
                 children: Ext.decode(treeConfig)
             }
         });

Best wishes,


More information about the Users mailing list