I want to display the KML from Cesium.
the source kml can read I was looking for from the following Github. https://github.com/AnalyticalGraphicsInc/cesium/tree/kml
build and run Cesium.
However, I do not know. How may be specified as in the kml.
What should be written after the following?
var viewer = new Cesium.Viewer('cesiumContainer');
There are a few different ways to load KML data, the easiest is by passing it a url to the KML or KMZ file you would like to read:
var kmlDataSource = new Cesium.KmlDataSource();
kmlDataSource.loadUrl('path/to/kml/or/kmz');
viewer.dataSources.add(kmlDataSource);
You can't read local files this way, that path needs to be on the server, but if you would like to be able to drag & drop KML or KMZ files into your app, you can enable that by calling
viewer.extend(Cesium.viewerDragDropMixin);
Finally, about 30 seconds ago I just added the ability to construct a KmlDataSource and load a url at the same time. If you sync up to the head of the branch you can do it in one line.
viewer.dataSources.add(KmlDataSource.fromUrl('path/to/kml/or/kmz'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With