# Adding New CZML DataSources w/o Removing Existing Data

**URL:** <https://community.cesium.com/t/adding-new-czml-datasources-w-o-removing-existing-data/7939>\
**Category:** CesiumJS\
**Created:** [January 25, 2019, 3:57am UTC](https://community.cesium.com/t/adding-new-czml-datasources-w-o-removing-existing-data/7939 "2019-01-25T03:57:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RG1](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/rg1/32/2103_2.png) [@RG1](https://community.cesium.com/u/RG1)\
**Post date:** [January 25, 2019, 3:57am UTC](https://community.cesium.com/t/adding-new-czml-datasources-w-o-removing-existing-data/7939/1 "2019-01-25T03:57:03Z")

</div>

**1. A concise explanation of the problem you’re experiencing.**

**I have a drop down toolbar that allows the user to select CZML files to add to Cesium. When the user selects one DataSource and then selects a different DataSource, the latter overwrites the first DataSource selection, i.e. removes it.**

**How can the user select both of the CZML datasources without removing any existing data?**

**Thank you!**

**2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.**

Sandcastle.addToolbarMenu([{  
text : ‘Basic’,  
onselect : function() {

}, {  
text : ‘blah’,  
onselect : function() {

var dataSourcePromiseS = Cesium.CzmlDataSource.load(czmlS);  
viewer.dataSources.add(dataSourcePromiseS);  
}  
}, {  
text : ‘Last 30’,  
onselect : function() {

var dataSourcePromise30 = Cesium.CzmlDataSource.load(czml30);  
viewer.dataSources.add(dataSourcePromise30);  
}  
}], ‘toolbar’);

``

**3. Context. Why do you need to do this? We might know a better way to accomplish your goal.**

**4. The Cesium version you’re using, your operating system and browser.**

---

<div class="post-metadata">

**Author:** ![RG1](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/rg1/32/2103_2.png) [@RG1](https://community.cesium.com/u/RG1)\
**Post date:** [January 25, 2019, 4:14am UTC](https://community.cesium.com/t/adding-new-czml-datasources-w-o-removing-existing-data/7939/2 "2019-01-25T04:14:13Z")

</div>

Also, the following does not work even when dropping CZML files in. However, I would like to do this via code.

viewer.extend(Cesium.viewerDragDropMixin, { clearOnDrop : false });

``

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [January 28, 2019, 12:44pm UTC](https://community.cesium.com/t/adding-new-czml-datasources-w-o-removing-existing-data/7939/3 "2019-01-28T12:44:04Z")

</div>

By default, Sandcastle will not remove anything when you select the different items. If you used an example like this as a reference:

> **[Cesium Sandcastle](https://sandcastle.cesium.com/?src=KML.html)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

Sandcastle.reset = function() {

viewer.dataSources.removeAll();

viewer.clock.clockRange = Cesium.ClockRange.UNBOUNDED;

viewer.clock.clockStep = Cesium.ClockStep.SYSTEM\_CLOCK;

};

``

Specifically, the dataSources.removeAll() function is what clears the previous data.

Notice the Sandcastle.reset function defined at the bottom:
