Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

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 did change some vector features style (through check-boxes) using style property :

var features = layer.features;

for( var i = 0; i < features.length; i++ ) {
  //features[i].style = { visibility: 'hidden' };
    features[i].style = 'none'; 


But now if I check the box again, it supposed to display again but nothing happens! I tried:

     features[i].style = 'block'; 
     features[i].style = 'delete'; 

then redraw the layer.. but this doesn't work

Any Idea ?

share|improve this question

It's my understanding that you need to change the display property of style:

features[i].style.display = 'none'; // hide


features[i].style.display = ''; // show. Set to anything but 'none'

Then you need to do a redraw on the layer after changing the vectors in it:


Of course.. I'm having trouble with this now too ( which is how I found this question). If I change it manually in the debugger it seems to work ( zooming in to cause a redraw) but in code it's not working for me at the moment.

Update: Too funny... I went back and looked with new eyes.. was missing the .style bit in some copy-paste edits! Glad I found your question ;)

share|improve this answer
in my experience this approach could fail in some cases when style is null. Similar solution provided by Rayiez works fine in such situations. – Andrew Nov 30 '13 at 20:30

To hide features

    for( var i = 0; i < features.length; i++ ) {
      features[i].style = { display: 'none' };

To display back the hidden features

    for( var i = 0; i < features.length; i++ ) {
      features[i].style = null;
share|improve this answer

Let me put it another way:

to hide:

vectorLayer.features[0].style.fillOpacity = 0;

to show:

vectorLayer.features[0].style.fillOpacity = 1;

i hope it helps you...

share|improve this answer
could fail if style is null... – Andrew Nov 30 '13 at 20:31

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.