Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want display different detail(layers) on different zoom level on OpenLayers map. I mean when zoom in should display lot of layers and when zoom out those unsuitable layers should hide automatically. Different layers should display on different zoom level ,not using layer switcher.

Can this do using OpenLayers?

If not what is the open source solution? If yes, pls give some example or links to get some idea

Thanks for reading and answering

share|improve this question
pls dont write OpenLayers as open layer, it leads to concept confusion... – Aragon May 8 '12 at 11:26
Ohh,Really sorry,I don't do that again – sacprasanna May 8 '12 at 11:49
up vote 1 down vote accepted

Although Aragons answer is good, max and minResolution properties of the OpenLayers.Vector (which the WMS layer inherits):

Set appropriate min and max scales at initialization, and you should get the same behavoiur as in Aragons example.

The only drawback is that you have to care about resulutions instead of zoom levels

share|improve this answer
@Aragon s answer seems to be more flexible and intuitive. It's deserves an accepted. – Magno C Dec 19 '12 at 10:39

you can do this with some programmatic way as registering map with zoomend :


{Object} If set as an option at construction, the eventListeners object will be registered with .


{Array(String)} Supported application event types. Register a listener for a particular event with the following syntax:, obj, listener);

Listeners will be called with a reference to an event object. The properties of this event depends on exactly what happened.

Solution Code:

var layer1 = new OpenLayers.Layer.WMS( "OpenLayers WMS",
        {layers: 'basic'}, {'displayInLayerSwitcher':false} );

var layer2 = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
    {layers: "landsat7"}, {'isBaseLayer': false});

var layer3 = new OpenLayers.Layer.WMS( "DM Solutions Demo",
    {layers: "bathymetry,land_fn,park,drain_fn,drainage," +
     transparent: "true", format: "image/png" });


map.addLayers([layer1, layer2, layer3]);'zoomend', this, function (event) {
        var zLevel = map.getZoom();     

        if( zLevel == 13 || zLevel == 14 || zLevel == 15  )
        if( zLevel == 16 || zLevel == 17 || zLevel == 18)


i hope it helps you...

share|improve this answer
Highly grateful to you for long and complete answer,I will try .Hope we will contact again – sacprasanna May 8 '12 at 13:27
I find this also – sacprasanna May 8 '12 at 13:29

Using layer "scales" property you can control which zoom levels are valid for the layer. The link sugested by sacprasanna is the best place to learn all this.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.