Using Cesium to visualize KML(KMZ) data

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

I need some help on how to properly use the KmlDataSource option, for example; where to store (host) my KML file. Can anyone help?

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

var viewer = new Cesium.Viewer(“cesiumContainer”);

var options = {
canvas: viewer.scene.canvas };

var kmllayer = viewer.dataSources.add(Cesium.KmlDataSource.load(’…kmls\2011_caribou.kmz’, options));

My kmls folder is currently in my site root

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I have 30 KML files that show a 3D heatmap with a predetermined style, each kml file represents a year. I have to find a way to animate the KML showing the change year by year in a web map. I found the CesiumJS and it seems like a viable option. Cesium ion works really well when I upload the data as a KMZ. It keeps the style and the correct height for each block, needless to say I’m pretty impressed with Cesium. However, do to licencing constraints I cannot use Cesium ion for the project. I want to use the KmlDataSource option in the CesiumJS library but I’m not sure what the best approach is for displaying my data. I’m very new to JavaScript and even newer to Cesium and I didnt really get a full grasp on how the KmlDataSource works.

4. The Cesium version you’re using, your operating system and browser.

Cesium 1.63.1

Windows 10

Preferably Google Chrome

Thanks for the kind words, and welcome to the Cesium community!

If you’re not using Cesium ion to host your KML files, you’ll need to host them on a web server. Either way, once you’re able to load the KML files into your CesiumJS scene, you’d have to write JavaScript code to detect when the year has changed in the timeline, and load the next KML file.

Is there anything particular about the Cesium ion licensing that prevents you from using it for your project? It would make this much easier, especially with upcoming tools we’re working on that’ll make it easier to drag and drop all those files and have them automatically appearing at specific time points.

Do you know of anything that can host KMZ/KML? I looked into GeoServer but I dont think it has the capabilities.

Its partly due to cost as we have limited funding that ion is not an option right now. It does sound like a really powerful set of tool though!

If they’re simply plain existing KML files, all you need is any generic HTTP static file server, nothing special.