Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 have four layers in the LayerSwitcher. When the map is loaded all the layers are checked by default. I do not want to show all Layers as checked.How do I uncheck a layer when the map is loaded?

share|improve this question
up vote 5 down vote accepted

Use the layer's setVisibility function to turn them off before you add them to the map.

share|improve this answer

You can get idea from the view page source code of this example.

In given below example, I have added village layer which will be loaded unchecked default on map load. In that code, I have used setVisibility() function.

var village = new OpenLayers.Layer.WMS("Village", "http://localhost:8090/geoserver/cite/wms",
              LAYERS: 'cite:Village_Boundary_geo',
              STYLES: '',
              format: format,
              transparent: true
              singleTile: true,
              ratio: 1,
              isBaseLayer: false,
              yx : {'EPSG:4326' : true}


share|improve this answer
Your answer would be more useful if it contained an example of the situation of the problem listed in the question and possibly some content from the link you provided. – Evil Genius Jun 23 '14 at 11:11

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.