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 am displaying multiple feature types using one layer in OpenLayers, like here:

 var **vector** = new OpenLayers.Layer.Vector("My Layer", { 
  maxExtent: new OpenLayers.Bounds(-1.09863,44.42907, 91.01074, 2.05840) 
  sphericalMercator: true,  
  protocol:  new OpenLayers.Protocol.WFS({   
  url: 'http://mydomain/geoserver/wfs', 
  featureType: **["mylayer_1","mylayer_2","mylayer_3"],** 
  featureNS: "http://mapmap.org", 
  srsName: "EPSG:3857", 
  version: "1.1.0", 
  extractAttributes: true, 
  isBaseLayer: false, 
  visibility: true 
   }) 
  }); 

now I want to make layer_2 invisible by setVisibility(false).. but I don't know how to select it. it seems like I just can control the whole layer (vector).

is there any way to control visibility of these layers ?

share|improve this question
add comment

1 Answer

You should use separate OpenLayers.Layer.Vector object for each WFS-layer. For example:

var mylayer_1 = new OpenLayers.Layer.Vector("My Layer 1", {
    ....
    featureType: "mylayer_1",
    ...
});

var mylayer_2 = new OpenLayers.Layer.Vector("My Layer 2", {
    ....
    featureType: "mylayer_2",
    ...
});
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.