[Users] Question on using WMS GetLegendGraphic with a GeoExt.tree.LayerNode

Andrew Stewart Andrew.Stewart at reddeer.ca
Mon Nov 22 23:51:01 CET 2010

Is it possible to show a legend graphic which is returned from my WMS GetLegendGraphic request next to each item on the LayerNode after it is expanded? (or before.. Or whenever as long as it shows).

I declare my layernode like so -

//Trails layerList
        layerList_Trails = new GeoExt.tree.LayerNode({
        "layer": layer_Trails,
        "isLeaf": false,
        "checked": false,
        "enableDD": true,
        "cls": "rootnode",
        "singleClickExpand": true,
        "listeners": {
        'checkchange' :  function(node, checked)
            // If a parent node is unchecked, uncheck all the children
            if (node.getUI().isChecked()) {
            if (!node.getUI().isChecked())
        "loader": {
            "param": "LAYERS"

Which is added to my root -

And then my treepanel

 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

Except previously when I declared my layers individually I had put an <img> tag with the right layer next to each.. But now I am declaring them in groups like -
         //Trails Group
         var layer_Trails = new OpenLayers.Layer.WMS("<img src='http://localhost/WebService/Request.aspx?request=GetLegendGraphic&version=1.1.1&format=image/png&layer=Asphalt' alt=''/>Trails", "http://localhost/WebService/Request.aspx",
         layers: ['Onstreet_Bike_Route', 'Mountain_-_Stunt_Biking', 'Equestrian', 'Gravel_or_Shale', 'Asphalt'],
                     VERSION: "1.1.1",
                     transparent: true
                    { isBaseLayer: false,
                      singleTile: true,
                      visibility: false,
                      buffer: 1,
                      ratio: 1
But this only puts the image on the actual group name and I need it to be beside each legend entry when it is expanded. Is there a place somewhere I can stick this image tag and either hard code the layer name or have it be returned from the childNodes of the tree and get it to show this image beside each childNode? Appreciate any assistance!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20101122/20b58fde/attachment-0001.htm 

More information about the Users mailing list