Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
1  
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
add comment

3 Answers 3

up vote 1 down vote accepted

Although Aragons answer is good, max and minResolution properties of the OpenLayers.Vector (which the WMS layer inherits): http://dev.openlayers.org/releases/OpenLayers-2.11/doc/apidocs/files/OpenLayers/Layer-js.html#OpenLayers.Layer.maxResolution

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
add comment

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

eventListeners

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

EVENT_TYPES

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

map.events.register(type, 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",
        "http://vmap0.tiles.osgeo.org/wms/vmap0",
        {layers: 'basic'}, {'displayInLayerSwitcher':false} );

var layer2 = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
    "http://t1.hypercube.telascience.org/cgi-bin/landsat7", 
    {layers: "landsat7"}, {'isBaseLayer': false});

var layer3 = new OpenLayers.Layer.WMS( "DM Solutions Demo",
    "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
    {layers: "bathymetry,land_fn,park,drain_fn,drainage," +
             "prov_bound,fedlimit,rail,road,popplace",
     transparent: "true", format: "image/png" });


layer2.setVisibility(false);
layer3.setVisibility(false);

map.addLayers([layer1, layer2, layer3]);

map.events.register('zoomend', this, function (event) {
        var zLevel = map.getZoom();     

        if( zLevel == 13 || zLevel == 14 || zLevel == 15  )
        {
            layer2.setVisibility(true);
        }
        if( zLevel == 16 || zLevel == 17 || zLevel == 18)
        {
            layer2.setVisibility(false);
            layer3.setVisibility(true);
        }

    });

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 trac.osgeo.org/openlayers/wiki/SettingZoomLevels –  sacprasanna May 8 '12 at 13:29
add comment

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
add comment

Your Answer

 
discard

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.