I have to update CzmlDataSource but before that i want to remove old one on every ajax call it load new data.
How can i remove old data and load new one.
This works - viewer.dataSources.add(Cesium.CzmlDataSource.load(json));
but it also keep adding on top of that. It does not remove old CzmlDataSource.
I tried few things
viewer.entities.removeAll();
//viewer.dataSources.remove(Cesium.CzmlDataSource.load(json));
for (var i = 0; i < viewer.dataSources.length; ++i) {
var dataSource = viewer.dataSources[i];
//if (dataSource.name === "simple") {
viewer.dataSources.remove(dataSource);
// break;
// }
}
Non of them are working....
Here is my Ajax call back code -
$.ajax({
url: "ajax/admin_ajax.php",
type: "POST",
cache: false,
data: {
tracker_req: "yes",
},
dataType: 'text',
success: function (result)
{
var result_json = $.parseJSON(result);
var json = [];
$.each(result_json["live_flights"], function( index, value ) {
json = value;
});
//console.table(json);
var json_empty = [];
$("#count_total_flights").html(result_json["live_flights_count"]);
$("#logged_in_operator").html(operator_icao_code);
viewer.dataSources.add(Cesium.CzmlDataSource.load(json));
}
});
Thanks
viewer.dataSources.removeAll();