[Users] Set visibility on Sub-layers

Paul james pauljame at gmail.com
Mon Dec 7 19:44:45 CET 2009


Andreas
I´m testing your patch...
But I think it isnt working well in a case...


I have that Openlayer Layer, the first layer ON and the next 2 OFF:
   new OpenLayers.Layer.MapServer("FederalRoads",
                _cgi, {
                    map: _mapfile,
                    "LAYERS": [
                    'Layer1ON',
                    'Layer2OFF',
                    'Layer3OFF'
                    ],
                    transparent: true,
                    format: "image/png"
                }, {
                    isBaseLayer: false,
                    buffer: 0,
                    displayInLayerSwitcher: false,
                    visibility: true
                })

The TreeView config :
 text: 'Roads',
                            expanded : true,
                            checked: false,
                            children:
                            [
                                {
                                    nodeType:
"gx_layerparam",
                                    layer: "FederalRoads",
                                    param: "LAYERS",
                                    item: "Layer1ON",
                                    text: "FederalRoads1",
                                    checked: true,
                                    uiProvider: ...
                                },{
                                    nodeType:
"gx_layerparam",
                                    layer: "FederalRoads",
                                    param: "LAYERS",
                                    item: "Layer2OFF",
                                    text: "FederalRoads2",
                                    checked: false,
                                    uiProvider: ...
                                },{
                                    nodeType:
"gx_layerparam",
                                    layer: "FederalRoads",
                                    param: "LAYERS",
                                    item: "Layer3OFF",
                                    text: "FederalRoads3",
                                    checked: false,
                                    uiProvider: ...
                                }
Everthing starts OK... So I deselect Layer1ON and select the other 2 layers
(Layer2 and Layer3)... Thats ok...
But, when I deselect the last layer in treeview(Layer3OFF), the other
checkbutton (Layer2OFF) is automatically deselected...

Why ? Is that a bug?

Thanks




On Mon, Oct 19, 2009 at 3:42 PM, Paul james <pauljame at gmail.com> wrote:

> Thats great Andreas...
>
> Thanks!
>
> Paul
>
>   On Sun, Oct 18, 2009 at 8:28 AM, Andreas Hocevar <ahocevar at opengeo.org>wrote:
>
>> Paul james wrote:
>>
>>> Ohh no :(
>>> Any other alternative to solve that?
>>>  ps.: Can you send that ticket url?
>>>
>>
>> I was thinking that you create a ticket. But hey, it's FOSS4G time and I'm
>> feeling generous, so here it is - even with patch and tests:
>>
>> http://trac.geoext.org/ticket/166
>>
>> Regards,
>> Andreas.
>>
>>  Paul
>>>
>>>
>>> On Wed, Oct 14, 2009 at 11:12 PM, Andreas Hocevar <ahocevar at opengeo.org<mailto:
>>> ahocevar at opengeo.org>> wrote:
>>>
>>>    Andreas Hocevar wrote:
>>>
>>>        Hi Paul,
>>>
>>>        the recommendations given so far should all work, but let Papa
>>>        Treenode speak from his experience:
>>>
>>>        The best thing to do is override the createNode function of
>>>        the loader, as documented in
>>>        http://www.extjs.com/deploy/dev/docs/?class=Ext.tree.TreeLoader.
>>>
>>>
>>>    which, unfortunately, will *not* work because GeoExt sets the
>>>    visibility in the node's render method, regardless of its checked
>>>    attribute. A tickdt with patch that fixes this would be in order I
>>>    guess.
>>>
>>>    Regards,
>>>    Andreas.
>>>
>>>
>>>
>>>
>>>        The createNode function is called with the attributes (attrs)
>>>        as argument, so you could check for attr.text and then set
>>>        attr.checked accordingly.
>>>
>>>        Regards,
>>>        Andreas.
>>>
>>>        Paul james wrote:
>>>
>>>            Thanks Matt...
>>>            I tried that:
>>>             nodeType: "gx_layer",
>>>                        id: "Streets",
>>>                        layer: "Streets",
>>>                        isLeaf: false,
>>>                        expanded : true,
>>>                  loader: {
>>>                              param: "LAYERS",
>>>                                         baseAttrs: {
>>>                                      uiProvider:
>>>            Ext.extend(Ext.tree.TreeNodeUI, {
>>>                                            render:
>>>            function(bulkRender) {
>>>             if(this.node.text == "Layer3")
>>>
>>>   this.node.layer.setVisibility(false);
>>>
>>> Ext.tree.TreeNodeUI.prototype.render.apply(this,
>>>            arguments);                                  }
>>>            ...
>>>              But all node´s layer are set off... How can I set the
>>>            subnode´s visibility separately?
>>>             Thanks
>>>             Paul
>>>
>>>            On Wed, Oct 14, 2009 at 11:50 AM, Matt Priour
>>>            <mpriour at kestrelcomputer.com
>>>            <mailto:mpriour at kestrelcomputer.com>
>>>            <mailto:mpriour at kestrelcomputer.com
>>>
>>>            <mailto:mpriour at kestrelcomputer.com>>> wrote:
>>>
>>>               Handle the 'render' event of the layer tree and
>>>            programmatically
>>>               uncheck the nodes that you don't want on.
>>>               The only disadvantage of this method is that depending
>>>            on timing the
>>>               application may or may not attempt to do GetMap
>>>            requests on the
>>>               layers you don't want. Though they still would not be
>>>            visible, if
>>>               you are calling a slow service or complex rendering is
>>>            involved,
>>>               then the GetMap requests can block other WMS service
>>>            requests.
>>>               Matt Priour
>>>               Kestrel Computer Consullting
>>>               *From:* Paul james <mailto:pauljame at gmail.com
>>>            <mailto:pauljame at gmail.com>>
>>>               *Sent:* Wednesday, October 14, 2009 9:39 AM
>>>               *To:* bartvde at osgis.nl <mailto:bartvde at osgis.nl>
>>>            <mailto:bartvde at osgis.nl <mailto:bartvde at osgis.nl>>
>>>
>>>               *Cc:* users at geoext.org <mailto:users at geoext.org>
>>>            <mailto:users at geoext.org <mailto:users at geoext.org>> ;
>>>            Andreas Hocevar
>>>               <mailto:ahocevar at opengeo.org <mailto:ahocevar at opengeo.org>>
>>>
>>>
>>>               *Subject:* Re: [Users] Set visibility on Sub-layers
>>>
>>>               Thanks bart...
>>>               But I need set all layers to build up my treeview, like
>>>            that:
>>>                    nodeType: "gx_layer",
>>>                                   layer: "Streets",
>>>                                   isLeaf: false,
>>>                                                  loader: {
>>>                                       param: "LAYERS",
>>>               ...
>>>                                  On Wed, Oct 14, 2009 at 11:16 AM,
>>>            <bartvde at osgis.nl <mailto:bartvde at osgis.nl>
>>>                <mailto:bartvde at osgis.nl <mailto:bartvde at osgis.nl>>>
>>> wrote:
>>>
>>>                   Hi Paul,
>>>
>>>                   only by using LAYERS: ['layer1', 'layer2'].
>>>
>>>                   Then later on, when you need more layers, you
>>>            should change the
>>>                   LAYERS
>>>                   param using the mergeNewParams function.
>>>
>>>                   Best regards,
>>>                   Bart
>>>
>>>                    > Hello guys... I have that set of sublayers :
>>>                    >
>>>                    > new OpenLayers.Layer.MapServer("Streets",
>>>                    >                 _cgi, {
>>>                    >                     map: _mapfile,
>>>                    >                     "LAYERS":
>>>                   ['Layer1','Layer2','Layer3','Layer4',
>>>                    > 'Layer5'],
>>>                    >                     transparent: true,
>>>                    >                     format: "image/png"
>>>                    >                 }, {
>>>                    >                     isBaseLayer: false,
>>>                    >                     buffer: 0,
>>>                    >                     displayInLayerSwitcher: false,
>>>                    >                     visibility: false
>>>                    >                 })
>>>                    >
>>>                    > I悲 like to start with Layer1 and Layer2 with
>>>            visibility true
>>>                   ... How can
>>>                    > I
>>>                    > do that?
>>>                    >
>>>                    > Paul
>>>                    > _______________________________________________
>>>                    > Users mailing list
>>>                    > Users at geoext.org <mailto:Users at geoext.org>
>>>            <mailto:Users at geoext.org <mailto:Users at geoext.org>>
>>>
>>>                    >
>>> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>>>                    >
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>>               _______________________________________________
>>>               Users mailing list
>>>               Users at geoext.org <mailto:Users at geoext.org>
>>>            <mailto:Users at geoext.org <mailto:Users at geoext.org>>
>>>
>>>               http://www.geoext.org/cgi-bin/mailman/listinfo/users
>>>
>>>
>>>
>>>
>>>
>>>
>>>    --    Andreas Hocevar
>>>    OpenGeo - http://opengeo.org/
>>>    Expert service straight from the developers.
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at geoext.org
>>> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>>>
>>>
>>
>>
>> --
>> Andreas Hocevar
>> OpenGeo - http://opengeo.org/
>> Expert service straight from the developers.
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20091207/c63ce283/attachment-0001.htm 


More information about the Users mailing list