Removing individual dataSources does not update viewer

I’m loading a small number (~4) of GeoJson dataSources, each with a small number (~2) of features. When I remove a single dataSource, the dataSource’s features are still visible in the viewer. The viewer’s dataSources collection contains the correct number of remaining dataSources. Only when I call viewer.resize() or when all of the dataSources have been removed does the viewer update properly, showing no features. This happens whether or not I set the destroy parameter to true:

viewer.dataSources.remove(datasource, true);
//nothing changes in the viewer until the last dataSource has been removed

viewer.resize(); //this causes the viewer to update correctly

viewer.dataSources.removeAll(); //this works as expected and as in Sandcastle


When I call viewer.resize() after removing a single dataSource, it is removed from the viewer. Am I missing something, or is this the intended behavior?


Can you provide code that reproduces the problem? I made a quick test case and it seems to be working correctly.

I downloaded a few geojson files from and tested with this sandcastle:

//Create the viewer

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var wi = Cesium.GeoJsonDataSource.fromUrl(’…/…/SampleData/WI.geo.json’);

var wv = Cesium.GeoJsonDataSource.fromUrl(’…/…/SampleData/WV.geo.json’);

var wy = Cesium.GeoJsonDataSource.fromUrl(’…/…/SampleData/WY.geo.json’);

Sandcastle.addToolbarButton(‘add wi’, function() {



Sandcastle.addToolbarButton(‘add wv’, function() {



Sandcastle.addToolbarButton(‘add wy’, function() {



Sandcastle.addToolbarButton(‘remove wi’, function() {



Sandcastle.addToolbarButton(‘remove wv’, function() {



Sandcastle.addToolbarButton(‘remove wy’, function() {



I have the same issue on cesium 1.7.1, using the viewer not in sandcastle

var data = Cesium.GeoJsonDataSource.load(‘data/mun.topojson’);



//viewer.dataSources.removeAll(); //works
viewer.dataSources.remove(data); //does not work

data is not what you think it is. It’s a Promise and not a KmlDataSource.

See my response in this thread for example code and details:

thank you, it works.