How to make my BaseLayerPicker pick from all my assets in cesium ions ?

I have a map with a cesium cesium Base Layer Picker,

Add the moment, I am adding a list of Imagery like this :

{

imageryProviderViewModels: ImageryHelperService.getImageryProviderViewModels((value: CesiumImageryProviders) => {

this.store$.dispatch(new SettingsStoreAction.SetNavigationSettings({settings : {providerVRMap : value} }));

}),

selectedImageryProviderViewModel: ImageryHelperService.getSelectedImageryProvider(settings.providerVRMap),

}

**Which basically, take from a function a list of Imagery I created and that are static in the code ex : **
static getImageryProviderViewModels(onChange?: (key: CesiumImageryProviders) => void) {

const imageryViewModels = ;

Object.keys(ImageryHelperService.DEFAULT_PROVIDERS).forEach(key => {

if (key in ImageryHelperService.DEFAULT_PROVIDERS) {

const provider = ImageryHelperService.DEFAULT_PROVIDERS[key];

imageryViewModels.push(new Cesium.ProviderViewModel({

name: provider.name,

iconUrl : Cesium.buildModuleUrl(provider.iconUrl),

category : provider.category,

tooltip : provider.tooltip,

creationFunction: () => {

if (onChange) { onChange(Number(key)); }

return provider.creationFunction();

}

}));

}

});

return imageryViewModels;

}

**Anyway, after adding my custom list, I would like to load the Imagery that are in the ION account. I have 3 solution for this, but I do not know which is possible

  1. ADD and REMOVE Imagery from the baseLayerPicker AFTER setting the initial array of Imagery. Is it poissible ?
  2. Sync the baseLayerPicker with all the assets in my Ions account ?
  3. Instead of assigning an array, assign a promise instead and add the layer when the promise is completed, so my **ImageryHelperService.getImageryProviderViewModels()would be just a Promise of an Array of ImageryProvider

Thank you

What I would do here is use the Cesium ion REST API to list all the assets in your account:

https://cesium.com/docs/rest-api/#operation/getAssets

Then of that list, take the ones that have a type of IMAGERY, and then add those to the base layer picker widget.

Note that you’ll need to create a token that has list permissions, since that’s not enabled by default.

Let me know if that works! That seems like a pretty useful idea, so you can easily explore all your assets like that. It might be useful to have it so when you select an imagery layer it’ll automatically fly to it, in case some imagery layers are not global.

Hello,
Thanks for the reply.
Yes, this is already my plan, but If a user drop assets to Ions, I would like the imagery picker to add and display the newly imported asset without refreshing the map, or destroy the widget.
The problem I have is not add the cesium imagery assets to the baseLayerPicker, the first time, but is to add and remove assets AFTER s****etting the initial array of Imagery

I tried to edit, reassign an array, etc… but the baseLayerPicker is never updated, If I want to display a new list of assets I need to.
The only way I found is by editing this Array
this.viewer.baseLayerPicker.viewModel.imageryProviderViewModels = ;

https://prnt.sc/qy6mih
But it looks to nested, and I do not know if there is a better way