[Users] opacity slider in a bbar - trouble connecting to selected layer

Eoin Mac Aoidh eoinyp at yahoo.com
Wed Jul 28 10:08:24 CEST 2010


Hi Bart,
Looking at the firebug console, the problem seems to be with my application of the patch.
Firebug says:"slider.setLayer is not a function"
Thus it would seem that the changes (accodring to your patch) which I pasted into lib/GeoExt/widget/LayerOpacitySlider.js, are not being reached.
Is there anything else I need to do to other than edit and save the layerOpacitySlider.js code?
I am using: 
OL 2.9.1
GeoExt 0.7
ExtJS 3.2.1 (also tested with 2.3.0)

Many thanks,
Eoin



--- On Tue, 27/7/10, Bart van den Eijnden (OSGIS) <bartvde at osgis.nl> wrote:

From: Bart van den Eijnden (OSGIS) <bartvde at osgis.nl>
Subject: Re: [Users] opacity slider in a bbar - trouble connecting to      selected layer
To: "Eoin Mac Aoidh" <eoinyp at yahoo.com>
Cc: users at geoext.org
Date: Tuesday, 27 July, 2010, 16:20

What versions of GeoExt and ExtJS are you using?

Your code looks okay, I am using something similar. Have you checked the
contents of node2.layer using Firebug console.log?

With "nothing happens", do you mean if you drag the slider it does not
apply to the attached layer?

Best regards,
Bart

> Thankyou Andreas and Bart.
> Bart, I looked at http://trac.geoext.org/ticket/301 and updated
> layerOpacitySlider.js accordingly.
> Thanks to your efforts, given the patch, I would expect to be able to call
>
> slider.setLayer(node.layer);
>
> to attach the layer to the slider, but nothing happens.
> My code is:
>
> var slider = new GeoExt.LayerOpacitySlider({ renderTo: document.body,
> width: 200,value: 100}); 
>
> ....then within the TreePanel:
>
> bbar: [{
>             text: "Remove layer from Map",
>             handler: function() {
>                 var node = tree.getSelectionModel().getSelectedNode();
>                 if(node) {
>                     map.removeLayer(node.layer);  
>                 }
>             }
>         },{
>             text: "Attach slider to selected layer",
>             handler: function() {
>                 var node2 = tree.getSelectionModel().getSelectedNode();
>                 if(node2) {
>                 slider.setLayer(node2.layer);
>                 }
>             }
>         }]
>
>
>
>
> Right, that's why I wanted to implement:
>
> http://trac.geoext.org/ticket/301
>
> to make it easier to attach a layer to the opacity slider on the fly.
>
> Best regards,
> Bart
>
>> Hi,
>>
>> On Jul 27, 2010, at 10:51 , Eoin Mac Aoidh wrote:
>>
>>> Hi list,
>>> I have a tree containing the layers in my map. It has a bbar with a
>>> button to remove a selected layer from the map. Following this
>>> template,
>>> I am trying to also add in an opacity slider for the selected layer in
>>> the bbar: So that you can either remove a selected layer, or change its
>>> opacity.
>>> I am having trouble connecting the slider to the selected layer.
>>> I suspect at least some of the
>  problem is with the line:
>>> "layer: tree.getSelectionModel().getSelectedNode().layer"
>>
>> The whole problem lies here. At the time you construct the tree, there
>> is
>> no selected layer yet. You should construct your OpacitySlider in a
>> listener to the tree's click event. In this listener, you also have to
>> remove an existing slider if there is one already.
>>
>> Regards,
>> Andreas.
>>
>>
>>> I would appreciate any help regarding how to connect the selected layer
>>> with the slider.
>>> Many Thanks,
>>> Eoin
>>>
>>> The following is the code I have:
>>>
>>> var tree = new Ext.tree.TreePanel({
>>>         region: "center",    //NBNBNBNB centER
>>>         title: "Map Layers",
>>>         width:
>  200,
>>>         autoScroll: true,
>>>         enableDD: true,
>>>         lines: false,
>>>         rootVisible: false,
>>>         root: new GeoExt.tree.LayerContainer({
>>>             layerStore: mapPanel.layers,
>>>             expanded: true
>>>         }),
>>>         bbar: [{
>>>             text: "Remove from Map",
>>>             handler: function() {
>>>                 var node =
>  tree.getSelectionModel().getSelectedNode();
>>>                 if(node) {
>>>                     map.removeLayer(node.layer);
>>>                 }
>>>             }
>>>         },{
>>>             xtype: "gx_opacityslider",
>>>             layer: tree.getSelectionModel().getSelectedNode().layer,
>>>             aggressive: true,
>>>             horizontal: true,
>>>             width: 120,
>>>         
>     plugins: new GeoExt.LayerOpacitySliderTip()
>>>         }
>>>          ]
>>>       });
>>>
>
>
>       _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>


-- 
Looking for flexible support on OpenLayers or GeoExt? Please check out
http://www.osgis.nl/support.html

Bart van den Eijnden
OSGIS
bartvde at osgis.nl




      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20100728/844bd339/attachment.htm 


More information about the Users mailing list