In a previous version of my application (which was built on OpenLayers 2.*), I had a requirement to show and hide imagery layers based on scale. I am trying to support this requirement on a Cesium version of the application.

I understand that Cesium doesn't support scale, and I am trying to figure out the best way to accomplish this.

Given some definition of what layers the user would like turned on (layer name), brightness, and alpha.

I am creating an imageryProvider from the layer definition, and then adding the WebServiceImageryProvider to the imageryLayers (collection).

                for (i = 0; i < layers.length; i++) {

                    imageryProvider = new Cesium.WebMapServiceImageryProvider({
                        url: layers[i].url,
                        layers: [layers[i].name],
                        maximumLevel : layers[i].minScale,
                        minimumLevel : layers[i].maxScale,
                        proxy: new Cesium.DefaultProxy(config.proxyConfig.url),
                        parameters : {
                            transparent : (i === 0) ? false : layers[i].transparentLayer,
                            format : 'image/jpeg'

                    this.wmsImagery[layers[i].name] = this.scene.globe.imageryLayers.addImageryProvider(imageryProvider);
                    this.wmsImagery[layers[i].name].alpha = layers[i].opacity;
                    this.wmsImagery[layers[i].name].maximumLevel = layers[i].minScale;
                    this.wmsImagery[layers[i].name].minimumLevel = layers[i].maxScale;

From the api documentation I am not sure what the values for maximumLevel and minimumLevel represent and how they should be determined?

In the openlayers version, once a user zooms in or out (changes scale) I then need to determine which layers need to be show or hidden. I think this design holds true for the Cesium version of the application. The difference is that would need to determine the current level-of-detail and then compare that value against the maximumLevel and minimumLevel attributes to determine which imagery layer(s) would need to be shown or hidden?

Thanks in advance


maximumLevel/minimumLevel represent the available data, not the data for visibility. I’ll make a note to improve documentation in this area.

It’s incorrect to say Cesium doesn’t have a zoom level, it’s just that the zoom level varies throughout the current view so there’s no single zoom level at any given time. The entire imagery system is still based on retrieving the correct image based on zoom level in that area of the screen.

Your use case is definitely something we need to make easier, so I’ve also written up this issue: https://github.com/AnalyticalGraphicsInc/cesium/issues/2612. I can’t promise a timeline, but if it turns out to be simple it could make the May 1st release (1.9). I’ll try to remember to update this thread if/when a pull request gets opened.

For now, the only options I can think of it to probably implement a custom imagery provider that simply aggregates other imagery providers and returns the correct tile/info based on the zoom level. The required interface can be seen here: http://cesiumjs.org/Cesium/Build/Documentation/ImageryProvider.html The only requirement would be the providers have the same tiling scheme and sizes. The way it would work is that for properties/methods that don’t take a level, you return the aggregated information (lowest minimumLevel value, highest maximumLevel value, etc…) and for properties that do take x,y,level, you simply delegate to the proper provider. You could probably copy and paste the Grid provider to jump start you and just replace the method implementations: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/GridImageryProvider.js

Hope that helps.