Possible Duplicate:
How can I switch baselayers as a user zooms in to the map in OpenLayers

I have a map that has two base layers and several overlays. One of the base layers only has 5 zoom levels. I would like to disable that base layer in the layer switcher when the map is zoomed outside of the range of that base layer. I have found how to do that with overlays in this forum at this link. I changed dataLayers to baseLayers. My problem seems to come when the base layer that I am trying to limit is the base layer selected when I zoom outside the range of that base layer. If I then select the other base layer, it appears as if the zoom control is locked up.

Any suggestions are greatly appreciated.


  • @iant:I'm pretty sure that this question is very different from your question. This question seems to be asking about what to do when the zoom level is outside the range of one of the base layers. Commented Jan 25, 2013 at 11:46
  • @DevdattaTengshe - I think the solution to my question will work here.
    – Ian Turton
    Commented Jan 25, 2013 at 11:52
  • @iant - my question was a little different, but the solution to your question that you referred to put me on the right tract, so that it did help me with an acceptable solution to my problem. Thanks for your comments. Commented Jan 25, 2013 at 17:30
  • Jerome please add a reference here to the chosen solution so that future readers know what worked. If you needed to adapt it before it worked it would be appropriate to add that here as answer. Commented Jan 25, 2013 at 20:59
  • @matt wilkie - I found a satisfactory solution to my situation by using "map.setBaseLayer(layer);" in a zoomend event to change the base layer when the map was zoomed out of the range of the layer with the limitations. By doing this, I no longer had the need to disable the layer in the layer switcher. Commented Jan 26, 2013 at 4:18


Browse other questions tagged or ask your own question.