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

笑着哭i 提交于 2019-12-24 15:18:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!