Beanshell:Toggle Layer Visibility

From OpenJUMP Wiki
Jump to: navigation, search

The following script toggles the visibility of all layers (ie if not visible, make visible and vice versa).

{
  import com.vividsolutions.jump.workbench.model.Layer;
  Iterator iter= wc.getLayerManager().getLayers().iterator();  
  while (iter.hasNext()) {
    Layer layer = (Layer)iter.next();
    layer.setVisible ( ! layer.isVisible());
  }
}


This script will make a layer called "street" visibile.

{
  import com.vividsolutions.jump.workbench.model.Layer;
  Layer layer = wc.getLayerManager().getLayer("street");
  if (layer != null) {
    layer.setVisible(true);
  }
}