Hi.<br>I know this is an old question, but I can&#39;t figure out why the usual method to add/remove layers from LayerSwitch on the base of zoom doesn&#39;t work for me.<br><br>I have two layers:<br><br>&nbsp;&nbsp;&nbsp; GMLcomuni = new OpenLayers.Layer.GML(&quot;GMLcomuni&quot;,&quot;IET2.gml&quot;, {isBaseLayer:true,group:&quot;base&quot;});<br>
&nbsp;&nbsp;&nbsp; GMLsezioni = new OpenLayers.Layer.GML(&quot;GMLsezioni&quot;,&quot;IET2.gml&quot;, {group:&quot;base&quot;,maxResolution: 10,visibility: false,displayInLayerSwitcher:false});<br>&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; map.addLayers([GMLcomuni,GMLsezioni]);<br>
&nbsp;&nbsp;&nbsp; layerswitch = new OpenLayers.Control.LayerSwitcher();<br>&nbsp;&nbsp;&nbsp; map.addControl(layerswitch);<br>&nbsp;&nbsp;&nbsp; map.events.register(&quot;zoomend&quot;,GMLsezioni, function(){<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(map.resolution&lt;10){<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.setVisibility(true);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //this.displayInLayerSwitcher=true;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; });<br><br>The setVisibility() method triggers both the changelayer and the <span class="code-string">visibilitychanged events, but the layerswitcher seems to ignore them, leaving only the first baselayer.<br>
</span>&nbsp;(and the layer get drawn on the map), but the layerswitcher control doesn&#39;t react. Debuggin with FB I&#39;ve seen that the layerswitcher.checkRedraw() method returns false, so the redraw() returns nothin, but I&#39;ve checked<span class="code-string"> that layerswitch.layerStates[1].visibility property before and after </span>setVisibility(), and they change so I would expect the checkRedraw to return true!. I&#39;m a bit confused...<br>
<br>Any hint?<br><br>Giovanni<br>