1. A concise explanation of the problem you're experiencing.
I'm using Cesium to display a live race runner's datas. I would like to update runner's datas using CZML datasource. For my use case, I need previously existing datas to be totally cleared before update.
The problem I'm facing is that CzmlDataSource->load() function does not clear existing datas as it is declared in the documentation: "Loads the provided url or CZML object, replacing any existing data.".
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
Problem can be reproduced pasting this code in sandcastle app:
"
var czmlPacket1 = [
{
"id" : "document",
"version": "1.0"
},
{
"id" : "point",
"name" : "Test point - packet 1",
"point" : {
"color" : {
"rgbaf": [1, 0, 1, 1]
},
"pixelSize": 40
},
"position": {
"cartographicDegrees": [1, 60, 1000]
}
}
];
var czmlPacket2 = [
{
"id" : "document",
"version": "1.0"
},
{
"id" : "point",
"name" : "Test point - packet 2",
"point" : {
"color" : {
"rgbaf": [1, 1, 0, 1]
},
"pixelSize": 20
},
"position": {
"cartographicDegrees": [2, 40, 1000]
}
}
];
var viewer = new Cesium.Viewer('cesiumContainer');
var dataSource = new Cesium.CzmlDataSource();
viewer.dataSources.add(dataSource);
dataSource.load(czmlPacket1).then(function ()
{
window.setTimeout(function ()
{
dataSource.load(czmlPacket2).then(function ()
{
console.log('packet 2 received, but dot hasn't been updated: color and position did not change.');
});
}, 2000);
});
viewer.zoomTo(dataSource);
"
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I need to do this to transparently update datas providing a live race preview.
I've tried using "process()" method instead of "load()" but I'm working with path estimated positions which are no longer valid when next update is made, so I really need to clear existing datas.
I found 2 workarounds for this:
- deleting datasource and creating a new one works, but this automatically reset my cusomized clock and timeline and I need to re-set it every time I update datas
- deleting datasource entities before calling load works but existing datas disappear while expecting request response
4. The Cesium version you're using, your operating system and browser.
Cesium 1.39, Windows 10, Chrome