Hello,
How would one remove the ‘Cesium World Terrain’ option in the menu, such that a user could not accidentally active it?
Hello,
How would one remove the ‘Cesium World Terrain’ option in the menu, such that a user could not accidentally active it?
Hi! You can customize the BasePlayerPicker and remove the Cesium World Terrain option. Please see the BasePlayerPicker
API for more details: BaseLayerPicker - Cesium Documentation.
@dzung Is there a specific way to remove one option, or do I need to construct the baseLayerPicker
myself with that specific option not used?
EDIT: This is inefficient. See next post for best answer.
For future reference of others - you don’t have to construct a new base layer, you can just open the element and remove it manually
const worldTerrainOptions = Cesium.Viewer.baseLayerPicker.container.getElementsByClassName(
"cesium-baseLayerPicker-item"
);
const worldTerrain = worldTerrainOptions[worldTerrainOptions.length - 1]; // Currently is the last option of this array
worldTerrain.parentNode?.removeChild(worldTerrain);
This will probably require a change when terrain becomes default.
Returning to say I found a better way that’s very easy:
Cesium.Viewer.baseLayerPicker.viewModel.terrainProviderViewModels.pop()
Another easy way to do this is to set the Viewer’s “terrainProviderViewModels” to an empty array.