Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display of KML in Cesium

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');
like image 756
ishizaki Avatar asked Nov 13 '14 13:11

ishizaki


1 Answers

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'));
like image 104
Matthew Amato Avatar answered Nov 14 '22 12:11

Matthew Amato