The cleanest thing would be to listen for zoom changes of the map and remove/add the layers accordingly. This can be done by assigning an event listener to each layer that checks if the map scale is still within the layer&#39;s min/maxscale and drop it accordingly.<br>
<br>Something like this (untested):<br><br>function isLayerAvailable (event){<br>  if (!event.zoomChanged ) {<br>     return;<br>  }<br>  var layer = this;<br>  var mapScale = layer.map.getScale();<br>  if ( mapScale &gt; layer.maxScale || mapScale &lt; layer.minScale){<br>
     layer.map.removeLayer(layer);<br>     //TODO: add the other layer here<br>  } <br>}<br><br>map.layers[0].events.on({<br>                 moveend: isLayerAvailable,<br>                 scope: this<br>            });<br>
<br>cheers,<br><br>Franz<br><br><div class="gmail_quote">2011/6/28 Alberto Valente <span dir="ltr">&lt;<a href="mailto:alb.valente@gmail.com">alb.valente@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi, I have 2 layers and one is available (min-maxscale) from scale 1000 to 200000 and the other from 200000 to 400000 (sat and aerial photos).<br>If the user changes the active layer from one to the other, the map becomes white (correctly since actual scale is not permitted for the other layer) but I&#39;d like to tell user that the scale is not available for this layer.<br>


<br>For example disabling the layer from layer chooser if the actual scale is not allowed for it<br>or by switching to layer&#39;s nearest allowed scale<br>or by auto-switching back to the other layer and launching an alert();<br>


<br>How to do that?<br><br>thank you<br><font color="#888888">alberto<br>
</font><br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
<br></blockquote></div><br>