1

Openlayers enables to declare multiple layers in one WMS layer class.

 var nasa_wms = new OpenLayers.Layer.WMS(
        "NASA Global Mosaic",
        "http://wms.jpl.nasa.gov/wms.cgi", 
        {
           layers: "modis, global_mosaic"
        });

When I add this layer to map, the items are coming together on the map. But sometimes I want to use a single layer to apply CQRS filter to "modis" layer or "global_mosaic". So I should use a single wms layer and add CQRS filter.

Is this possible, or should I separate layers as two layers.

1

In OpenLayers 2 when you define a new OpenLayers.Layer object, it will be handled as one layer independently from how many layers you requested from the WMS server.

If you would like to get two separate layers to make different operations on them, you must separate the two layers into two OpenLayers.Layer objects.

var nasa_glob = new OpenLayers.Layer.WMS(
    "NASA Global Mosaic",
    "http://wms.jpl.nasa.gov/wms.cgi", 
    {
       layers: "global_mosaic"
    });

var nasa_modis = new OpenLayers.Layer.WMS(
    "NASA Modis",
    "http://wms.jpl.nasa.gov/wms.cgi", 
    {
       layers: "modis"
    });

map.addLayers([nasa_glob, nasa_modis]);

For further references on OpenLayers.Layer object properties and functions, please consult the OpenLayers 2 API documentation.

  • However, it is possible to ask the WMS server to change the rendering styles for individual layers even if it sends them out as one combined layer. What is CQRS filter? – user30184 Sep 7 '14 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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