Cesiumjs: How to update UrlTemplateImageryProvider's url?

I have UrlTemplateImageryProvider Layer on my Cesium earth.

var imageryProvider = new Cesium.UrlTemplateImageryProvider({
    url: 'servicerul?styleset=hybrid&x={x}&y={y}&z={z}'
var imageryLayer = new Cesium.ImageryLayer(imageryProvider, {
    maximumTerrainLevel: 20

Now I need to change the UrlTemplateImageryProvider’s url, which will be changed to servicerul?styleset=raster&x={x}&y={y}&z={z}, after clicking a button.

And show the replaced Imagery layer to Cesium earth.

Do you have any idea?


You will need to crate a new UrlTemplateImageryProvider with the updated URL. Then you can remove the old imageryLayer from layerCollections and add the new one in it’s place.