How to hide (or remove) a pre-configured layer from the layers-panel in WorldWind

697 views Asked by At

I would like to hide one of the "standard" layers (such as Stars, atmosphere, nasa blue marble and so on) in the layer panel, and to visualize and to make enabled/disabled by ticks only layers added by me. Naturally, the hidden layers have to be always active. Is it possible?

2

There are 2 answers

0
sayyedbagher musavi On

You can add this method.

private void removeLayerWithName(String str) {
    wwd.getModel().getLayers().forEach(layer -> {
        if (layer.getName().equals(str)) {
            wwd.getModel().getLayers().remove(layer);
            return;
        }
    });
}

and in your code you call it as removeLayerWithName("Stars");.

Other layer-names that may be useful for you:

  • Stars
  • Atmosphere
  • NASA Blue Marble Image
  • Blue Marble May 2004
  • i-cubed Landsat
0
hadi.mansouri On

If you want to remove layers programmatically use @sayyedbagher solution. Another solution is changing the initial settings of WorldWind by providing an xml file containing initial settings (including initial layers). Base on documents of gov.nasa.worldwind.Configuration class here https://worldwind.arc.nasa.gov/java/latest/javadoc/index.html?gov/nasa/worldwind/Configuration.html and comments in the file worldwind.xml here https://github.com/nasa/World-Wind-Java/blob/master/WorldWind/src/config/worldwind.xml you could determine yourself initial layers as permanent initial settings of WorldWind in your app.