OpenLayers already has a Map moveend event handler that will check to see if the layer is still in range (maxExtent, minResolution, maxResolution, minScale & maxScale are all tested) You should use one of these configuration options (maxResolution, minResolution are easiest) on the layers and let OL do the turning on/off layers for you.
To have your GeoExt LayerNodes respond by enabling/disabling when layers are in/out of range, you can apply the autoDisable patch [1] attached to Ticket #235 (http://trac.geoext.org/attachment/ticket/235) [1] http://trac.geoext.org/attachment/ticket/235/autoDisableLayerNode.patch Matt Priour Kestrel Computer Consulting From: IT Intern Sent: Thursday, October 28, 2010 9:08 AM To: [email protected] Subject: [Users] Disable Nodes on Zoom Event Hello GeoExt Users, I have a zoom event that when a user zoom in and out of my map certain layers I setVisibility(false). Now what I would like to do is have another event inside that event which disables the nodes of those layers when their setVisibilty(false) and enables them back when setVisibility(true). I have some code and it kinda works, but the problem is the checkchange event does not only work when the zoomend event is done, but also anytime a user clicks the layer nodes. I played a little with stopPropagation and that didn't do anything for me. Actually I think my zoomend event could be much better coded and I would really love some suggestions. I appreciate everyone taking their time to help me :) elshae Code: map.events.on({ "zoomend": function (e) { layerTree.on("checkchange", function (node, checked) { alert(node.text + "Inside event"); if(checked == false) node.disable(); else if(checked == true) node.enable(); }); if (this.getZoom() > 7) { tib_villages.setVisibility(true); tib_lakes.setVisibility(true); tib_townships.setVisibility(true); } else { tib_villages.setVisibility(false); tib_lakes.setVisibility(false); tib_townships.setVisibility(false); //alert(layerTree.tib_villages.node.text); if (this.getZoom() > 5) { infrastructure.setVisibility(true); geography.setVisibility(true); geography2.setVisibility(true); tib_countys.setVisibility(true); } else{ infrastructure.setVisibility(false); geography.setVisibility(false); geography2.setVisibility(false); tib_countys.setVisibility(false); } }//end else }//end function (e) }); //end map.events.on -------------------------------------------------------------------------------- _______________________________________________ Users mailing list [email protected] http://www.geoext.org/cgi-bin/mailman/listinfo/users
_______________________________________________ Users mailing list [email protected] http://www.geoext.org/cgi-bin/mailman/listinfo/users
