<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><span><span class="Apple-tab-span" style="white-space:pre">        </span></span></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">HI,</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">Thanks a million Andreas!</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">I´ve been tearing my hair out for months on and off for the following EASY solution.......</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt;
"><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div><div><font class="Apple-style-span" size="2"> map.events.on({</font></div><div><font class="Apple-style-span" size="2"> "zoomend": function (e) {</font></div><div><font class="Apple-style-span" size="2"> if (this.getZoom() > 12) {</font><span class="Apple-style-span" style="font-size: small; "> </span></div><div><font class="Apple-style-span" size="2"> layer_Flurbloeke.setVisibility(true);</font></div><div><font class="Apple-style-span" size="2"> <span class="Apple-tab-span" style="white-space:pre">        </span> </font><span class="Apple-style-span" style="font-size: small; ">layerTree.getRootNode().findChild('layer', layer_1, true).enable();</span><span
class="Apple-style-span" style="font-size: small; "> </span></div><div><font class="Apple-style-span" size="2"> } else {</font></div><div><font class="Apple-style-span" size="2"> layer_1.setVisibility(false);</font><span class="Apple-style-span" style="font-size: small; "> </span></div><div><font class="Apple-style-span" size="2"> layerTree.getRootNode().findChild('layer', layer_1, true).disable();</font></div><div><font class="Apple-style-span" size="2"> </font><span class="Apple-style-span" style="font-size: 13px; "> </span></div><div><font class="Apple-style-span" size="2"> }</font></div><div><font class="Apple-style-span" size="2">
}</font></div><div><font class="Apple-style-span" size="2"> });</font></div></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">This checks/unchecks the layer and disables the treenode on the required zoom level!!!</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">Yours,</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">Rob</div><div
style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div> <div style="font-size: 10pt; font-family: arial, helvetica, sans-serif; "> <div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "> <font size="2" face="Arial"> <hr size="1"> <b><span style="font-weight:bold;">Von:</span></b> Andreas Hocevar <ahocevar@opengeo.org><br> <b><span style="font-weight: bold;">An:</span></b> Robert Buckley <robertdbuckley@yahoo.com> <br><b><span style="font-weight: bold;">Cc:</span></b> "users@geoext.org" <users@geoext.org> <br> <b><span style="font-weight: bold;">Gesendet:</span></b> 17:43 Montag, 28.November 2011<br> <b><span style="font-weight: bold;">Betreff:</span></b> Re: [Users] How to disable a Treenode ?<br> </font> <br>You are confusing layer (i.e. instances of OpenLayers.Layer, which<br>have a setVisibility() method) and node (i.e. instances of<br>Ext.tree.TreeNode, which have a config
option "disabled", which only<br>controls the initial enabled/disabled state upon instance creation,<br>and enable() and disable() methods). As you found out, you are using<br>setVisibility in the correct context (the layer), but you are totally<br>off controlling the node.<br><br>Search the archives, this question was thoroughly answered a few weeks<br>ago. IIRC even a code snippet was provided.<br><br>Andreas.<br><br>On Mon, Nov 28, 2011 at 5:21 PM, Robert Buckley<br><<a ymailto="mailto:robertdbuckley@yahoo.com" href="mailto:robertdbuckley@yahoo.com">robertdbuckley@yahoo.com</a>> wrote:<br>> Hi,<br>> I want to disable treenode like in this webapp (<a href="http://www2.visdat.de/" target="_blank">http://www2.visdat.de/</a>) look<br>> at "Freie Webdienste" which nicely disables treenodes after a certain<br>> resolution.<br>> The relevant code is this....<br>> "<br>> map.events.register('zoomend', map, function (e) {<br>>
if (map.getZoom() < minZoom) {<br>> map.zoomTo(minZoom)<br>> };<br>> if (map.getZoom() > maxZoom) {<br>> map.zoomTo(maxZoom)<br>> };<br>><br>> for (var k = 0; k < layerArray.length; k++) {<br>> var layerId = layerArray[k][8];<br>> if (layerTree.getNodeById(layerId)) {<br>> if ((map.getResolution() >= layerArray[k][9] &&<br>> map.getResolution() <= layerArray[k][10]) || (layerArray[k][9] == null
&&<br>> layerArray[k][10] == null)) {<br>> layerTree.getNodeById(layerId).enable();<br>> }<br>> if (layerArray[k][9] != null && layerArray[k][10] !=<br>> null) {<br>> if (map.getResolution() <= layerArray[k][9] ||<br>> map.getResolution() >= layerArray[k][10]) {<br>> layerTree.getNodeById(layerId).disable();<br>> }<br>> }<br>>
};<br>> }<br>><br>><br>> "<br>> In my Application I wanted to disable a treenode when the zoomlevel goes<br>> above 12, but although api docs (<a href="http://www.myext.cn/ext-3.2.1/docs/" target="_blank">http://www.myext.cn/ext-3.2.1/docs/</a>) say<br>> that a treenode has a disabled property, firebug says otherwise<br>> According to the geoext docs<br>> (<a href="http://geoext.org/lib/GeoExt/widgets/tree/LayerNode.html" target="_blank">http://geoext.org/lib/GeoExt/widgets/tree/LayerNode.html</a>)<br>> "Configuration properties in addition to those listed<br>> for Ext.tree.TreeNode."<br>><br>> So I looked at the Ext.tree.TreeNod propertie and saw this...<br>> disabled : Boolean<br>> true to start the node disabled<br>> So, I tried this...<br>> map.events.on({<br>>
"zoomend": function (e) {<br>> if (this.getZoom() > 12) {<br>><br>> layer_1.setVisibility(true);<br>> layer_1.disabled="false";<br>><br>><br>> } else {<br>> layer_1.setVisibility(false);<br>> layer_1.disabled="true";<br>><br>> var mapcenter = getMapCenter();<br>><br>> }<br>> }<br>> });<br>> and my console reports "has no method 'disable'"<br>> The setVisibility(true); works ok, but this method isn´t even documented!<br>> I am not a javaascript guru
unfortunately, but I thought I could understand<br>> the docs...now i´m not too sure.<br>> Thanks for any help,<br>> Rob<br>><br>><br>><br>> _______________________________________________<br>> Users mailing list<br>> <a ymailto="mailto:Users@geoext.org" href="mailto: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><br>-- <br>Andreas Hocevar<br>OpenGeo - <a href="http://opengeo.org/" target="_blank">http://opengeo.org/</a><br>Expert service straight from the developers.<br><br><br> </div> </div> </div></body></html>