[Users] Group layer visiblity

Gary Duckers coffi at hotmail.co.uk
Sun Jun 17 19:05:03 CEST 2012


Hi,

    I am new to web mapping and I am wondering if anyone can help me explain
why my group layer is set to visible and is also added to container node in
my layertree even though I thinkI have set the options as to omit the group
layer from the overlaycontainernode and visibility set to false.

Here is my code:

                                                

                

                                //Create the map object

           var map = new OpenLayers.Map('map_element',{

                                                                maxExtent:
new OpenLayers.Bounds(

                                                                -128 *
156543.0339,

                                                                -128 *
156543.0339,

                                                                128 *
156543.0339,

                                                                128 *
156543.0339),

 
maxResolution: "auto",                 

                                                                units: 'm',

                                                                projection:
'EPSG:27700',

                                                    displayProjection: new
OpenLayers.Projection("EPSG:27700"),   

                                                                controls:[

 

                               

// Create WFS layer          

var wfs_layer = new OpenLayers.Layer.Vector("Editable WFS", {

    strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],

    protocol: new OpenLayers.Protocol.WFS({

    reportError: true,

    visibility: true,   

                url: "http://gislidar.serveftp.com/geoserver/wfs",

    featureType: "edd",

    featureNS: "http://lidartest.org",

    geometryName: "geom",

    version: "1.1.0",

                srsName: "EPSG:27700",

                projection: WGS84_google_mercator, // specified because it
is different than the map 

    })

  });   

var groupLayer = new OpenLayers.Layer.WMS("Lidar Visualisation(Group)",

    "http://gislidar.serveftp.com/geoserver/wms", {

        layers: [

            "lidartest:HillSha_dtm141"       

        ],

        transparent: true,

        format: "image/gif",

                                isBaseLayer: false,

                    buffer: 0,

                    // exclude this layer from layer container nodes

                    displayInLayerSwitcher: false,

                    visibility: false

    }

);

 

 

// Create OpenStreet Map layer 

var osm = new OpenLayers.Layer.OSM();  

 

 

var mapPanel, printPage;

// set up viewport

new Ext.Viewport({

        layout: "border",

        items: [{

            region: "north",

            contentEl: "title",

            height: 130

        }, {

                                                region: "west",

                                                title: 'Adjust
Transparency',

                                                collapsible: true,

            contentEl: "layertree",

                                                width: 220,

            split: true

                                }, {

                                                region: "south",

                                                title: 'Feature Table',

            contentEl: "south",

            height: 150,

                                                collapsible: true,

            split: true

        }, {

            region: "center",

            id: "mappanel",

            title: "Map",

            xtype: "gx_mappanel",

            map: map,

            layers: [osm, google_hybrid,google_physical,google_satellite,
groupLayer, wfs_layer],

            split: true,

                                                center: new
OpenLayers.LonLat(-239570.659113951,6764338.19414546),

            zoom: 10,

            title: 'Map',

            region: "east",

            contentEl: "guide",

            width: 220,

                                                collapsible: true,

            split: true,

                                                items: [{

                                                xtype: 'panel',

                                                title: 'Info',,          

                                                height: 180

                                                },{

                                                xtype: 'panel',

                                                title: 'Status',

                                                id: "status",

                                                height: 140

                                                }]

        }]

    });

 

    mapPanel = Ext.getCmp("mappanel");

 

 

// create our own layer node UI class, using the TreeNodeUIEventMixin

    var LayerNodeUI = Ext.extend(GeoExt.tree.LayerNodeUI, new
GeoExt.tree.TreeNodeUIEventMixin());

        

    // using OpenLayers.Format.JSON to create a nice formatted string of the

    // configuration for editing it in the UI

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

        nodeType: "gx_baselayercontainer",

                                expanded: true,

    }, {

        nodeType: "gx_overlaylayercontainer",

        expanded: true,

    }, {

        nodeType: "gx_layer",

        layer: "Lidar Visualisation(Group)",

                                expanded: true,

        isLeaf: false,

        // create subnodes for the layers in the LAYERS param. If we assign

        // a loader to a LayerNode and do not provide a loader class, a

        // LayerParamLoader will be assumed.

        loader: {

            param: "LAYERS"

        }

    }], true);

 

    // create the tree with the configuration from above

    tree = new Ext.tree.TreePanel({

        border: true,

        renderTo: "layertree",

        region: "west",

        title: "Layers",

        enableDD: true,

                                width: 220,

        split: true,

        collapsible: true,

        collapseMode: "mini",

        autoScroll: false,

        plugins: [

            new GeoExt.plugins.TreeNodeRadioButton({

                listeners: {

                    "radiochange": function(node) {

                        alert(node.text + " is now the active layer.");

                    }

                }

            })

        ],

        loader: new Ext.tree.TreeLoader({

            // applyLoader has to be set to false to not interfer with
loaders

            // of nodes further down the tree hierarchy

            applyLoader: false,

            uiProviders: {

                "layernodeui": LayerNodeUI

            }

        }),

        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)

        },

        listeners: {

            "radiochange": function(node){

                alert(node.layer.name + " is now the the active layer.");

            }

        },

        rootVisible: false,

        lines: false,

    });

 

Thanks

Gary

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20120617/25862ab8/attachment-0001.htm 


More information about the Users mailing list