<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi Bart,<br>Looking at the firebug console, the problem seems to be with my application of the patch.<br>Firebug says:"slider.setLayer is not a function"<br>Thus it would seem that the changes (accodring to your patch) which I pasted into lib/GeoExt/widget/LayerOpacitySlider.js, are not being reached.<br>Is there anything else I need to do to other than edit and save the layerOpacitySlider.js code?<br>I am using: <br>OL 2.9.1<br>GeoExt 0.7<br>ExtJS 3.2.1 (also tested with 2.3.0)<br><br>Many thanks,<br>Eoin<br><br><br><br>--- On <b>Tue, 27/7/10, Bart van den Eijnden (OSGIS) <i><bartvde@osgis.nl></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Bart van den Eijnden (OSGIS) <bartvde@osgis.nl><br>Subject: Re: [Users] opacity slider in a bbar - trouble connecting to
selected layer<br>To: "Eoin Mac Aoidh" <eoinyp@yahoo.com><br>Cc: users@geoext.org<br>Date: Tuesday, 27 July, 2010, 16:20<br><br><div class="plainMail">What versions of GeoExt and ExtJS are you using?<br><br>Your code looks okay, I am using something similar. Have you checked the<br>contents of node2.layer using Firebug console.log?<br><br>With "nothing happens", do you mean if you drag the slider it does not<br>apply to the attached layer?<br><br>Best regards,<br>Bart<br><br>> Thankyou Andreas and Bart.<br>> Bart, I looked at <a href="http://trac.geoext.org/ticket/301" target="_blank">http://trac.geoext.org/ticket/301</a> and updated<br>> 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,<br>> 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 href="http://trac.geoext.org/ticket/301" target="_blank">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<br>>>> 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<br>> 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<br>>> 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:<br>> 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 =<br>> 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>>>> <br>> plugins: new GeoExt.LayerOpacitySliderTip()<br>>>> }<br>>>> ]<br>>>> });<br>>>><br>><br>><br>> _______________________________________________<br>> Users mailing list<br>> <a ymailto="mailto:Users@geoext.org" href="/mc/compose?to=Users@geoext.org">Users@geoext.org</a><br>> <a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a><br>><br><br><br>-- <br>Looking for flexible support on OpenLayers or GeoExt? Please check out<br><a
href="http://www.osgis.nl/support.html" target="_blank">http://www.osgis.nl/support.html</a><br><br>Bart van den Eijnden<br>OSGIS<br><a ymailto="mailto:bartvde@osgis.nl" href="/mc/compose?to=bartvde@osgis.nl">bartvde@osgis.nl</a><br><br></div></blockquote></td></tr></table><br>