问题
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?
回答1:
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.
回答2:
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
来源:https://stackoverflow.com/questions/51056384/how-to-hide-or-remove-a-pre-configured-layer-from-the-layers-panel-in-worldwin