[Users] gx_layercontainer filter:

Brian Marble brianmarble at landez.com
Thu Jan 28 17:30:38 CET 2010


Hey,

I am trying to filter a gx_layercontainer (see below). No matter what I do
all of my map.layers show in this branch of the tree. I want to have more
control over the contents of all branches of the tree. It looks like the
filter function just needs to be overridden on my part but I am unable to
make it work as below.

My test code below is taken from
http://dev.geoext.org/trunk/geoext/examples/tree.html 

Can anyone point out my oversights?

Thanks,
Brian

ar options = {
        projection: new OpenLayers.Projection("EPSG:900913"),
        displayProjection: new OpenLayers.Projection("EPSG:4326"),
        theme: null,
        units: "m",
        maxResolution: 156543.0339,
        maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
20037508.34, 20037508.34)
//        allOverlays: true
    };
    	
map = new OpenLayers.Map('mapContainer', options);

var treeConfig = new OpenLayers.Format.JSON().write([{
        nodeType: "gx_baselayercontainer",
        text: "Base Layers"
    }, {
        nodeType: "gx_overlaylayercontainer",
        text: "Over Layers",
        expanded: false,
        loader: {
	}
    }, {
        nodeType: "gx_layercontainer",
        text: "Special Layers",
        expanded: false,
        loader: {
		filter: function(record) {
		      var layer = record.get("layer");
//	     	 	return (!layer.isBaseLayer && layer.name == "2000
Census - Population (TC)");
	     		return !layer.isBaseLayer;
	     }
	     
		} 
	}
    ], true);

var tree = new Ext.tree.TreePanel({
        border: true,
        region: "west",
        title: "Layers",
        width: 200,
        split: true,
        collapsible: true,
        collapseMode: "mini",
        autoScroll: true,
        loader: new Ext.tree.TreeLoader({
            applyLoader: false
        }),

        root: {
            nodeType: "async",
            children: Ext.decode(treeConfig)
        },
        listeners: {
            "insert": registerRadio,
            "append": registerRadio
        },
        rootVisible: false,
        lines: false,
        bbar: [{
            text: "Show/Edit Tree Config",
            handler: function() {
                treeConfigWin.show();
                Ext.getCmp("treeconfig").setValue(treeConfig);
            }
        }]
    });

______________________________________________
Brian Marble
LandEZ Corp.    
W - 435 787 9003
C - 435 881 3117
F - 435 787 9004
BrianMarble at LandEZ.com





More information about the Users mailing list