1. A concise explanation of the problem you're experiencing.
I have used Cesium for a couple days and it is so amazing.Recently I gonna try to load wmts in Cesium and it works fine for me.But when I try to reset/remove/change my first wmts layers to show another one..it doesn't show well. I don't know how to solve it.
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
var viewer = new Cesium.Viewer('cesiumContainer',{
.....
Cesium.WebMapTileServiceImageryProvider({
url: "http://t0.tianditu.com/vec_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=vec&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles",
layer: "tdtVecBasicLayer",
style: "default",
format: "image/jpeg",
tileMatrixSetID: "GoogleMapsCompatible",
show: true
})
});
var testProvider1 =new Cesium.WebMapTileServiceImageryProvider({
url: url+'/geoserver/gwc/service/wmts',
layer: 'obt:changjian_2016',
style: '',
format: 'image/png',
tileMatrixSetID: 'EPSG:4326',
tilingScheme:new Cesium.GeographicTilingScheme(),
maximumlevel: 15,
tileMatrixLabels : ['EPSG:4326:0', 'EPSG:4326:1', 'EPSG:4326:2','EPSG:4326:3', 'EPSG:4326:4', 'EPSG:4326:5','EPSG:4326:6', 'EPSG:4326:7', 'EPSG:4326:8','EPSG:4326:9', 'EPSG:4326:10', 'EPSG:4326:11', 'EPSG:4326:12', 'EPSG:4326:13', 'EPSG:4326:14', 'EPSG:4326:15'],
alpha: 1.0,
show: true
});
var testProvider2=new Cesium.WebMapTileServiceImageryProvider({
url: url+'/geoserver/gwc/service/wmts',
layer: 'obt:changjian_2016_f',
style: '',
format: 'image/png',
tileMatrixSetID: 'EPSG:4326',
tilingScheme:new Cesium.GeographicTilingScheme(),
maximumlevel: 15,
tileMatrixLabels : ['EPSG:4326:0', 'EPSG:4326:1', 'EPSG:4326:2','EPSG:4326:3', 'EPSG:4326:4', 'EPSG:4326:5','EPSG:4326:6', 'EPSG:4326:7', 'EPSG:4326:8','EPSG:4326:9', 'EPSG:4326:10', 'EPSG:4326:11', 'EPSG:4326:12', 'EPSG:4326:13', 'EPSG:4326:14', 'EPSG:4326:15'],
alpha: 1.0,
show: true
});
function cjtoumingWMTS() {
viewer.imageryLayers.addImageryProvider(testProvider1)
}
function cjyingyangWMTS() {
viewer.imageryLayers.addImageryProvider(testProvider2)
}
....
//I use billboard to change wmts layers
//viewer.imageryLayers.removeAll(); removed my glob also,so terrible
//
Sandcastle.reset = function() {
viewer.dataSources.removeAll();
viewer.entities.removeAll();
viewer.imageryLayers.removeAll();
viewer.clock.clockRange = Cesium.ClockRange.UNBOUNDED;
viewer.clock.clockStep = Cesium.ClockStep.SYSTEM_CLOCK;
};
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I have some KML files to show also,when I change,the Sandcastle.reset works fine.
I use viewer.dataSources.add(Cesium.KmlDataSource.load(url, options)) to load kml
and viewer.dataSources.removeAll(); to remove
4. The Cesium version you're using, your operating system and browser.
"version": "1.40.0",
system:win7,
browser:chrome