Preventing use of higher level tiles when lower level ones are unavailable (WMTS)

Thomas,

This is a really poorly documented feature in Cesium and something we can do a lot better with. Just to jump right into it, I think this example code will provide exactly what you need, no changes to Cesium necessary:

var viewer = new Cesium.Viewer(‘cesiumContainer’, {

imageryProvider : false,

baseLayerPicker: false

});

var wmts = new Cesium.WebMapTileServiceImageryProvider({

url : “https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryTopo/MapServer/WMTS/tile/1.0.0/USGSImageryTopo/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}”,

layer : ‘USGSImageryTopo’,

style : ‘default’,

format : ‘image/png’,

tileMatrixSetID : ‘default028mm’,

maximumLevel: 16

});

var layers = viewer.imageryLayers;

layers.add(new Cesium.ImageryLayer(wmts, { minimumTerrainLevel: 6 }));

Here’s a Runnable demo version: https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/#c=ZVJNa+MwEP0rwpe4EKRkD2XJuqGQwhJI2LLOthdfJvbEFasPI8lO05D/XslWwGnti2bevHkjvenAkI7jEQ15IAqPZIWWt5K+9Ll0UvbhSisHXKGZTMm5UMR/XEKN5vRsdMcrz16QAwiL0wHdg8UNnNA88/I/mggW6nL3q1Dh77zuUTp7q/qK+y00Oy4wR9PxEte3KmkUb43wgkXy5lxjF4wFOQkNVeC4ViDCudYdA1PW3DKD1jE7dLTsX/47j313utHMKwY1NOx1u8uZ8+psTmd09q3ynLuTwAs7hwm34Ax/z9HdxDH4q4/xtNLiUiTxWUR4Ej/55EvnScRt6B/wCg/QCnfNH7SR4ALQPztrVH2F3HiU9dOIPPvxU8prmYR3Llu5wQ7FgszvgwfRjGBFP1gwY9gFGt3tLbS+asApVFU6sms9qkqDm347iOQqKO3QGL8yUfCeXO6CWjJNsv6Sy2GsRy4bbVwwNKWUOZSNAOdN2rd+bxwtrQ20jF1JWcU7wquHIvmymUVCSgHWeuTQCpHzDyySZcZ8/Q1NaKi4qv94v/2lQsnbfLkZkpTSjPnwO8tpLfZgRh0/AQ

Basically, I defined a single layer and have it disabled completely until you hit zoom level 6, so the globe is the default blue when the demo starts but as you zoom in it will appear when you hit level 6. You could also use a different base imagery layer as the base and turn it off at layer 6 at the same time yours turns on.

The poorly named minimumTerrainLevel/maximumTerrainLevel options to the ImageryLayer constructor turn on/off visualization of that layer at the specified zoom levels.

I’m going to write up an issue to better improve the API here and make it much more obvious how to implement this (often requested) functionality.

Let me know if you still have questions. Thanks!