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