gpt4 book ai didi

javascript - 在 Web WorldWind 中切换图层

转载 作者:行者123 更新时间:2023-11-30 20:44:55 26 4
gpt4 key购买 nike

我是 Web WorldWind 的新手,如果这是一个简单的问题,请原谅我,但我还没有在文档或其他地方找到解决方案。我有以下内容:

<div style="position: absolute; top: 5px; left: 5px;">
<!-- Create a canvas for Web WorldWind. -->
<canvas id="canvasOne" width="1040" height="630">
Your browser does not support HTML5 Canvas.
</canvas>
</div>

<script>
var wwd;
window.addEventListener("load", eventWindowLoaded, false);

// Define the event listener to initialize Web WorldWind.
function eventWindowLoaded() {
// Create a WorldWindow for the canvas.
wwd = new WorldWind.WorldWindow("canvasOne");
// Add some image layers to the WorldWindow's globe
//wwd.addLayer(new WorldWind.BingAerialWithLabelsLayer());.
wwd.addLayer(new WorldWind.BingRoadsLayer());

// Add a compass, a coordinates display and some view controls to the WorldWindow.
wwd.addLayer(new WorldWind.CompassLayer());
wwd.addLayer(new WorldWind.CoordinatesDisplayLayer(wwd));
wwd.addLayer(new WorldWind.ViewControlsLayer(wwd));
}
</script>

本地图显示时,我想添加一个切换开关以在道路图层和高分辨率航拍窗口之间切换。感谢您的帮助。

最佳答案

设置 bool 值 enabled 属性以显示/隐藏单个图层。

// Create the roads and aerial imagery layers and set the initial visability
var aerialLayer = new WorldWind.BingAerialWithLabelsLayer(),
roadsLayer = new WorldWind.BingRoadsLayer();
aerialLayer.enabled = true;
roadsLayer.enabled = false;

// Add the layers to the WorldWindow (globe)
wwd.addLayer(aerialLayer);
wwd.addLayer(roadsLayer);

// Toggles the display of the roads and aerial imagery layers
function toggleLayers() {
aerialLayer.enabled = !aerialLayer.enabled;
roadsLayer.enabled = !roadsLayer.enabled;
}

仅供引用:WorldWindow (wwd) 对象有一个 layers 数组属性,您可以在其中访问图层。

参见:WorldWind.Layer

另请参阅:layers in WorldWind.WorldWindow

关于javascript - 在 Web WorldWind 中切换图层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48813820/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com