[Users] problem with TreeNodeRadioButton and first layer in tree

36 views
Skip to first unread message

Robert Buckley

unread,
Mar 6, 2012, 2:55:47 PM3/6/12
to us...@geoext.org
Hi,

I am trying to test the functionality of the radionode plugin. I have built a test app which lets the user switch the active layer and then use the getfeatureinfo tool to call the attributes.

The behaviour is rather strange though. The top layer in the tree does not give me the featureinfo output UNLESS it is the first layer to be active. But if layer 1 is activated first all the other layers will not give featureinfos!!?!

On the other hand, If I activate any of the other layers...ie. layer 2,layer 3 or layer 4, in any order, they all give a getfeatureinfo response EXCEPT for Layer 1!!!!


It is most probably something very simple to do with radio button activation or the getfeatureinfo tool, but i have looked for examples and can´t find anything that could help me.

It is also rather irritating that the layer name is taken from the openlayers "layer" config (ie. the name as it is stored in geoserver), and not from the "text" config which means that I can´t give the getFeatureinfo responses an understandable layer name.

If anyone could help I´d be most grateful,

cheers

Rob.

//CODE

    var LayerNodeUI = Ext.extend(GeoExt.tree.LayerNodeUI, new GeoExt.tree.TreeNodeUIEventMixin());
        
    var treeConfig = [{
        nodeType: "gx_baselayercontainer",
        hidden: true,
    }, {
        nodeType: "gx_overlaylayercontainer",
        expanded: true,
        loader: {
            baseAttrs: {
                radioGroup: "infoLayers",
                uiProvider: "layernodeui"
            }
        }
    }];
    var featureInfo = new OpenLayers.Control.WMSGetFeatureInfo({
   infoFormat: "application/vnd.ogc.gml",   
        queryVisible: true,
        drilldown: true,
        highlightOnly: true,
        maxFeatures: 10,
eventListeners: {
                    "getfeatureinfo": function(e) {                       
                        var items = [];
                        Ext.each(e.features, function(feature) {
                            items.push({
                                xtype: "propertygrid",
                                title: feature.fid,
                                source: feature.attributes
                            });
                        });
new GeoExt.Popup({
                url: "/geoserver/ows",
                title: "getFeatureInfo",
                layout: "border",
                region:"east",
                width: 250,
                height: 450,
                layout: "accordion",
                bodyStyle: 'background-color:#FFF;,font-size:14px;',
                autoScroll: true,
                map: mapPanel.map,
                location: e.xy,
                //location: e.xy,
                //lonlat: mapPanel.map.getLonLatFromPixel(e.xy),
                // html: e.text,
                maximizable: false,
                resizable: false,
                collapsible: false,
                items: items 
                }).show(); 
        }
        }
    });
    map.addControl(featureInfo);
   // featureInfo.activate();
    
    
    treeConfig = new OpenLayers.Format.JSON().write(treeConfig, true);


    tree = new Ext.tree.TreePanel({
        border: true,
        region: "west",
        title: "Layers",
        width: 250,
        split: true,
        collapsible: true,
        collapseMode: "mini",
        autoScroll: true,
        plugins: [
            new GeoExt.plugins.TreeNodeRadioButton({
                listeners: {
                    "radiochange": function(node) {
                        selLayer = node.layer;
                        featureInfo.activate();
                        featureInfo.layers = [selLayer];
                    }
                }
            })
        ],
        loader: new Ext.tree.TreeLoader({

            applyLoader: false,
            uiProviders: {
                "layernodeui": LayerNodeUI
            }
        }),
        root: {
            nodeType: "async",
            children: Ext.decode(treeConfig)
        },
        rootVisible: false,
        lines: false,

    });

Robert Buckley

unread,
Mar 7, 2012, 3:37:16 AM3/7/12
to Robert Buckley, us...@geoext.org
Hi I have modified my tree but I am having a problem understanding how to use the radiochange function.


Firstly I don´t understand why the plugin has a listener AND the tree has listener.

Secondly I can´t figure out why the first node creates havoc. If the first node is the first to be active, then the other nodes do not work. However any other node is first active, then all others work apart from the first node.!?!?!?

I am simply trying to active the getFeatureInfo control for the active node.

If anyone can explain my error, I´d be most grateful,

Yours,

Rob

//my code

    tree = new Ext.tree.TreePanel({
        border: true,
        region: "west",
        title: "Layers",
        width: 250,
        split: true,
        collapsible: true,
        collapseMode: "mini",
        autoScroll: true,
        plugins: [
            new GeoExt.plugins.TreeNodeRadioButton({
                listeners: {
                    "radiochange": function(node) {
                  activeNode = node;
              if(activeNode == node)
               {
                 featureInfo.activate();
                 selLayer = node.layer;
                         featureInfo.layers = [selLayer];
                 
               }
               else
               {
                 featureInfo.deactivate();
               }
                   
                   
                    }
                }
            })
        ],
        loader: new Ext.tree.TreeLoader({
            uiProviders: {
                "layernodeui": LayerNodeUI
            }
        }),
        root: {
            nodeType: "async",
            children: Ext.decode(treeConfig)
            // Don't use the line above in your application. Instead, use
            //children: treeConfig
            
        },
        listeners: {
            "radiochange": function(node){
             //   alert(node.layer.name + " is now the the active layer.");
                                activeNode = node;
              if(activeNode == node)
               {
                 featureInfo.activate();
                 selLayer = node.layer;
                         featureInfo.layers = [selLayer];
                 
               }
               else
               {
                 featureInfo.deactivate();
               }
            }
        },
        rootVisible: false,
        lines: false,

    });


Von: Robert Buckley <robertd...@yahoo.com>
An: "us...@geoext.org" <us...@geoext.org>
Gesendet: 20:55 Dienstag, 6.März 2012
Betreff: [Users] problem with TreeNodeRadioButton and first layer in tree
_______________________________________________
Users mailing list
Us...@geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users


Robert Buckley

unread,
Mar 7, 2012, 1:25:28 PM3/7/12
to us...@geoext.org
Thanks..


"As far as I recall, you are not even supposed to be using the TreeNodeRadioButton plugin anymore when using GeoExt 1.1"..

If I am not supposed to be using the TreeNodeRadioButton what should I be using instead?

I did read that "children: treeConfig" should be used instead of "children: Ext.decode(treeConfig)" but when I do, this happens...http://maps.zgb.de/geoportal/treenodes.html !! 

yours,

Rob



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


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1913 / Virus Database: 2114/4855 - Release Date: 03/06/12


Andreas Hocevar

unread,
Mar 7, 2012, 1:59:27 PM3/7/12
to Robert Buckley, us...@geoext.org
Looks like the tree.js example was a bit misleading. I just made a few
improvements:

https://github.com/geoext/geoext/commit/fd54a9818df33cd2b1ab7ab4e4adb846347586ed

Let us know if this answers your questions.

Andreas.

--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.

Reply all
Reply to author
Forward
0 new messages