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();
};