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);
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?

Bart

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 https://github.com/johan/world.geo.json/tree/master/countries/USA 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() {

viewer.dataSources.add(wi);

});

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

viewer.dataSources.add(wv);

});

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

viewer.dataSources.add(wy);

});

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

viewer.dataSources.remove(wi);

});

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

viewer.dataSources.remove(wv);

});

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

viewer.dataSources.remove(wy);

});

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.add(data);

if(flag){

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

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: https://groups.google.com/d/msg/cesium-dev/Bf9MwBgJN8w/5WfUFprBqSgJ

thank you, it works.