openlayers / ol-cesium

OpenLayers - Cesium integration
http://openlayers.org/ol-cesium/
BSD 2-Clause "Simplified" License
990 stars 323 forks source link

Changing ol layer's source doesn't work in Cesium #697

Open jheijari opened 5 years ago

jheijari commented 5 years ago

As a developer, I'd like to be able to change layer's source.

I'm using ol to show Bing Maps. I have different ol sources for Road, Aerial and AerialWithLabels imagery sets. I have one ol layer so I can maintain the correct position/index all the time. Switching the layers imagery works by changing the source in ol, but the change doesn't get synchronized to Cesium.

gberaudo commented 5 years ago

Hi @jheijari, it is probably possible to handle this. See https://github.com/openlayers/ol-cesium/blob/master/src/olcs/AbstractSynchronizer.js.

When adding a layer we could listen for layer 'change:source' event and recreate the synchronized objects. However this is fairly low level and if you need this feature only for 1 layer you are probably better trying the following workaround: