简体   繁体   English

在OpenLayers 3中预组合多层

[英]Precompose multiple layers in OpenLayers 3

I have made an Openlayers layer-spy example , but with 5 layers added to the map. 我制作了一个Openlayers layer-spy示例 ,但是在地图上添加了5个图层。 I want to be able to toggle between the different layers, and set them as "spy-layer" and background-layer with a dropDown or something. 我希望能够在不同的层之间切换,并使用dropDown或其他方式将它们设置为“间谍层”和背景层。 How is that possible? 那怎么可能?
All the examples I have seen, are only using 1 layer as "spy-layer" and 1 layer as background. 我所看到的所有示例都仅使用1层作为“间谍层”,并使用1层作为背景。

My experience with Openlayers is not that great, so please be kind to me! 我对Openlayers的体验不是很好,所以请对我好一点! =) =)

Thanks in advance! 提前致谢!

Use two layers in the map, as in the ol3 layer-spy example. 在地图中使用两个图层,例如ol3 layer-spy示例。 The first layer is the background layer. 第一层是背景层。 The second layer, which is above the first layer, is the spy layer. 在第一层上方的第二层是间谍层。

And to change the background layer you can use: 要更改背景层,您可以使用:

map.getLayers().setAt(0, newBackgroundLayer);

To change the spy layer: 更改间谍层:

And to change the background layer you can use: 要更改背景层,您可以使用:

map.getLayers().setAt(1, newSpyLayer);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM