I am trying to dynamically display/hide an imagery overlay based on the map zoomlevel. It try the code below, it would work on IE 7 but not for other browsers. Is there another way to dynamically show/hide the overlayswitcher option on the client-side.
function ShowAerial(iZoomLevel) {
var map = Map1.GetOpenLayersMap();
if (map) {
var controls = map.getControlsByClass('OpenLayers.Control.LayerSwitcher');
if (controls[0]) {
for (var iIndex = 0; iIndex < controls[0].layerStates.length; iIndex++) {
if (controls[0].baseLayers[iIndex].layer.name == 'Hybrid') {
controls[0].baseLayers[iIndex].inputElem.style.display = (map.getZoom() >= iZoomLevel) ? 'block' : 'none' ;
controls[0].baseLayers[iIndex].labelSpan.style.display = (map.getZoom() >= iZoomLevel) ? 'block' : 'None';
break;
}
}
}
}
}