How to listen to change in selected basemap imagery?

I want to respond when the user selects a new basemap. I don’t see any specific events for this. Am I missing one?

I noticed that the reference for the selectedImagery member of BaseLayerPickerViewModel states:

Gets or sets the currently selected imagery. This property is observable.

This suggests I might be able to observe a property change here to get what I want. Using definitonChanged as suggested by the Property reference, I try this:




But this produces an error: Cannot read property ‘addEventListener’ of undefined

It seems I don’t get definitionChanged here. What am I doing wrong?



In the docs, when we refer to “observable” properties, this is a Knockout concept. (see for more info) The Knockout observable properties can be obtained using Cesium.knockout.getObservable and then you can subscribe to changes.

Cesium.knockout.getObservable(viewer.baseLayerPicker.viewModel, ‘selectedImagery’).subscribe(function(value) {



This will run the given function whenever the value of selectedImagery changes. In this case, “value” will then be a ProviderViewModel which has its own set of properties such as “name” above.

Thank you!

HI Everyone,
I have a question. When the user select a basemap, the basemap should be shown when the browser reloaded or the a new browser is opened… How to achieve that???

Best regards,