Search code examples
javascriptrestcesiumjs

Cesium KML polling data


I have an application where KML data is either being generated and or updated every second. Currently I am mapping this data onto cesium using

var viewer = new Cesium.Viewer('cesiumContainer');
viewer.dataSources.add(Cesium.KmlDataSource.load('link to data stream'));

This works great other than the data never gets updated after the initial pull. What would be the best way to update the kml data in cesium every second or two so the new data will be reflected on my map?

Thanks!


Solution

  • As of Cesium 1.19 (2016-03), the KML Data Source supports NetworkLinks with refreshMode=onInterval. When the timer reaches the interval, the data source auto-updates the KML. If the KML auto-updates in Google Earth then it should likewise auto-update in Cesium.

    As being a web application, be aware of cross-domain requests. If the KML URL resides on a server other than where the Cesium HTML pages are hosted, then the service for the KML must set Access-Control-Allow-Origin property in the HTTP header of the response otherwise it will fail to load.