简体   繁体   中英

Precompose multiple layers in OpenLayers 3

I have made an Openlayers layer-spy example , but with 5 layers added to the map. 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. How is that possible?
All the examples I have seen, are only using 1 layer as "spy-layer" and 1 layer as background.

My experience with Openlayers is not that great, so please be kind to me! =)

Thanks in advance!

Use two layers in the map, as in the ol3 layer-spy example. 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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