replacing BaseLayerPicker in CesiumViewerWidget?


I wonder if it was ever intended, or possible to replace the
BaseLayerPicker, or the list of possible layers in CesiumViewerWidget?

what I'd like to do is simply to have a different list of imagery
providers. to achieve this, I tried the following:

- replace the baseLayerPicker object:

        var widget = new CesiumViewerWidget({});

        // place & start

        // override the base layer imagery providers
        var imageryLayers = widget.centralBody.getImageryLayers();
        var providerViewModels =
        widget.baseLayerPicker = new
Cesium.BaseLayerPicker(widget.baseLayerPickerContainer, imageryLayers,

now this almost works - but the old drop-down menu remains in place, and
the new dropdown menu is put on top of it. this is despite the fact that
it seems in BaseLayerPicker.prototype.destory() provisions are taken to
clean the container element:

        var container = this.container;

- replace baseLayerPicker.viewModel :

as above, bust instead of creating anew BaseLayerPicker:

        widget.baseLayerPicker.viewModel = new
Cesium.BaseLayerPickerViewModel(imageryLayers, providerViewModels);

this doesn't work

- replace CesiumViewerWidget.createImageryProviders

CesiumViewerWidget.createImageryProviders = myCreateImageryProviders;

this doesn't seem to have an effect

thus, what is the proper way to do this, if at all?


anyway, I added a ticket with a suggested solution:


As a public service announcement for others stumbling on this thread: the syntax for the BaseLayerPicker has changed since this thread started. As of b28 I managed to create my own replacement using these steps:

New HTML on my page:
<div id="baseLayerPickerContainer" style="position:absolute;top:24px;right:24px;width:38px;height:38px; border:3px solid red"></div>

var viewer = new Cesium.Viewer('cesiumContainer',{imageryProvider:false, baseLayerPicker:false});

var imageryViewModels = ; // I populate this as an array of ProviderViewModel objects
... populate it here...

var blp2 = new Cesium.BaseLayerPicker('baseLayerPickerContainer', {
// globe: Cesium.Ellipsoid.WGS84, // Psych! this is wrong.
  globe:viewer.scene, // Yep, this is right
  imageryProviderViewModels : imageryViewModels