Remove World Terrain Option? (Solved)

Hello,

How would one remove the ‘Cesium World Terrain’ option in the menu, such that a user could not accidentally active it?

image

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?

@dzung any clarification on this?

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.

1 Like

Returning to say I found a better way that’s very easy:

Cesium.Viewer.baseLayerPicker.viewModel.terrainProviderViewModels.pop()

1 Like