Czml with Server-sent Events

Hi Hannah,

I am going to update a CzmlDataSource by Server-sent Events. I go through the document about "EventSource and Streaming". But no code example is provided for how to update CzmlDataSource object when a SSEs comes. I read docs of CzmlDataSource, and guess call load() method of CzmlDataSource object when a SSEs update received. Am I right? Could you provide a simple example for me?



Sorry, I’m not very familiar with SSEs, but yes, I imagine you could use the load method. Something like this:

var entities;
czmlSSE.onmessage = function(e) {
if (Cesium.defined(entities)) {
entities = viewer.dataSources.add(Cesium.CzmlDataSource.load(;


This function assumes you’re sending a full CZML file from the server. It removes the old data and adds the new values.

How you want to accomplish this really depends on what is being sent from the server.



Actually, never mind, it looks like there’ s a better to update the CZML.

You can use CzmlDataSource.process. That way you won’t have to add/remove your CZML with every change. Process will incrementally add new data to your existing CZML data source.