Switch to a newly create ImageryLayerCollection

Hi all,

I am trying to maintain two different ImageryLayerCollections in my program. Use one ImageryLayerCollection to maintain the baselayers created by Cesium’s ImageryProviders, and use another ImageryLayerCollection to maintain the baselayers created by my customized ImageryProviders.

I want to be able to switch back and forth between the two ImageryLayerCollections. Since viewer.scene.imageryLayers is a readonly attribute, I am confusing of how to switch to the ImageryLayerCollection that contains my customized baselayers. Please see the sample code below:

var myImageryLayerCollection = new Cesium.ImageryLayerCollection(); // this is the ImageryLayerCollection to maintain my customized ImageryProviders.

myImageryLayerCollection.addImageryProvider(new myImageryProvider({

}));

viewer.scene.imageryLayers = myImageryLayerCollection; //Here, I am trying to switch to the newly create ImageryLayerCollection, but this doesn’t work.

Thanks in advance,

Steven

Hello Steven,

It looks like you can’t change the imagery layer collection after the globe has been created. In order to switch, I think you’ll have to do imageryLayers.removeAll(), then add all of the layers from the other set.

Best,

Hannah