隐藏后如何在OpenLayers中显示矢量要素?

时间:2012-09-29 10:17:56

标签: vector filtering openlayers

我确实使用样式属性更改了一些功能样式(通过复选框):

var features = layer.features;

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

layer.redraw();

现在,如果我再次检查该框,它应该再次显示但没有任何反应! 我试过了:

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

然后重绘图层..但这不起作用

任何想法?

1 个答案:

答案 0 :(得分:2)

试试这个:

// set style
    features[i].style = null;
// or
    features[i].style = {display:'none'};

// redraw feature
layer.drawFeature(features[i]);