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 ?

1 Answer 1


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",

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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