I look at the sandcastle example:
What can I do if I want to remove all of the czml that is a part of “simple.czml” only? I don’t want to reset everything.
I look at the sandcastle example:
What can I do if I want to remove all of the czml that is a part of “simple.czml” only? I don’t want to reset everything.
Keep track of the data source object so you can pass it to the remove function.
var dataSource = new Cesium.CzmlDataSource();
dataSource.load(’…’);
viewer.dataSources.add(dataSource);
then,
viewer.dataSources.remove(dataSource);
Any way to reference by some ID or something else besides reference to dataSource?
DataSources have a “name” property which you can check, but it is not required to be specified, and it is not required to be unique. But, depending on your use case, perhaps you can make sure your app always uses data sources with unique names. This code will remove the first dataSource with the name “simple”.
for (var i = 0; i < viewer.dataSources.length; ++i) {
var dataSource = viewer.dataSources[i];
if (dataSource.name === “simple”) {
viewer.dataSources.remove(dataSource);
break;
}
}
We’ve had another user ask for a similar ID, so I added an item to the roadmap to look into it: https://github.com/AnalyticalGraphicsInc/cesium/issues/1045