Imagery layer switcher

Hi, I am complete beginner with the Cesium.
I am working on small app with using of a few ToolbarButtons. After clicking on the button 3D model and Imagery Layer appers. When I click on another button another 3D model and Imagery Layer appears but previous layer is still there. Is there any easy solution how to switch between the layers, the same ways as models? Here is the sample of the code:

Sandcastle.addToolbarButton(‘1953’, function() {

var layers = viewer.imageryLayers;

layers.addImageryProvider(new Cesium.TileMapServiceImageryProvider({

url : ‘do_app/web_1953’,

maximumLevel : 17,

}));

var position = Cesium.Cartesian3.fromDegrees(17.2583, 49.5871, 256);

var heading = Cesium.Math.toRadians(2);

var pitch = 0;

var roll = 0;

var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, heading, pitch, roll);

var model3 = viewer.entities.add({

name : ‘rok 1953’,

position : position,

orientation : orientation,

model : {

uri: ‘do_app/modely/1953.gltf’,

}

});

viewer.trackedEntity = model3;

});

Sandcastle.addToolbarButton(‘2003’, function() {

layers.addImageryProvider(new Cesium.TileMapServiceImageryProvider({

url : ‘do_app/web_2003’,

maximumLevel : 17,

}));

var position = Cesium.Cartesian3.fromDegrees(17.2583, 49.5871, 255);

var heading = Cesium.Math.toRadians(2);

var pitch = 0;

var roll = 0;

var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, heading, pitch, roll);

var model4 = viewer.entities.add({

name : ‘rok 2003’,

position : position,

orientation : orientation,

model : {

uri: ‘do_app/modely/2003.gltf’,

}

});

viewer.trackedEntity = model4;

});

Sandcastle.reset = function() {

viewer.entities.removeAll();

};

If you actually want to remove all layers, you can call viewer.imageryLayers.removeAll(); However, if you merely want to hide/show a layer, you can set layer.show to true or false. In your example code, layers.addImageryProvider returns an instance of the layer that was just added, so you can save that value if you want to toggle rather than remove.