when load a CZML file, the last CZML object still exists

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

On the user interface there is a button to load in CZML file, it can load the objects in CZML file when first click. But when I click it again to load another CZML file, the objects from the first CZML file still exist, and overlap with the objects newly loaded from the new CZML file. The problem is the same in this demo from Sandcastle(****https://www.google.com/url?q=https%3A%2F%2Fcesiumjs.org%2FCesium%2FBuild%2FApps%2FSandcastle%2F%23c%3DdZPBbtswDIZfRfAOdYBM7q5tGqzIOgxDsQ5Nscu8gyLRiTBZ8iTKbTLk3SvaTuMsWA6ORf78%2BIuSW%2BFZq%2BEZPLthFp7ZAoKONf%2FRxfIL2S0XzqLQFvzF5Lq0pS0K9kVYZYBVOj1iY5xQpW0TTNsm4p2BGiwmpHIy0iv%2FE8Fvl2BAovN5mb2jyvedusyIOi7kQqm7Nr3c64CQ%2BqYCuRF2DWU2ZZuu9edUH6asEiYA1VfRStTOjtP5hP0tLWPJ7yMI1bmlNRn1KfC2a1I%2FdoGcWGzIcmdpZ0l0oOdAtiYdtefIXW2S4Ovy4RtvhA%2FQSzgKvwbkHkI02EM7I7dKdWKGbhj2kaUEiqWLXsJ372odIIGHA1mkNp%2Fe0pxs5dT6QO4PkR8JgYaYnxH%2F0e%2Bcq5%2Fc%2F2T7QXwyEfDe%2BfORsGEm0tngDDlcn06iqztyR0z6uw1P8II5bnTgdEzh5%2BUvEu%2BzaTYLuDUw7%2Fkfdd04jyx6k3NeINSNEQihWEX5O7WRIRz2OLpjB3f0a1zQZPxKrJLTiHB9zKFrri6bl1HEQIWj0L60s%2BLgZ6Z0y7S6Sbfz9DspMyaNCCFlqmjMUu%2FSzZ3PiqQ%2FKaNj1Hb90II3YkuSzYf5fR%2FknM%2BKtDyvQufMSvgxsd8kbhuglnTNs147%2FsyS8BU&sa=D&sntz=1&usg=AFQjCNHryNsZmPQh0Uq8N6dru2m3p9M_ow), I cut a picture here: The red points are from the first CZML file, the white points are from the second CZML file. I checked the properties of Cesium.CzmlDataSource in documentation of Cesium, it says "load(czml, options) : Loads the provided url or CZML object, replacing any existing data. " So from documentation it should replace the existing data, but actually it didn’t. Could anyone help me to get through this? Any help would be appreciated. Many thanks!

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

please see it in the demo link from Sandcastle.

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.

Cesium 1.57, windows, both chrome and firefox browser I have tried.

Kind Regards,

Kathy

I have fixed this problem, it needs to judge whether the viewer.dataSources is empty or not, if it’s not empty, should delete the items at first, adding codes like below:
if(viewer.dataSources.length){
viewer.dataSources.removeAll(false);//destroy();//remove(dataSource);
}

``

Thanks for posting the solution you found here! It’s always appreciated.