Mapping KML to Cesium

I want to display KML from cesium.

The kml source can read, which I was looking for from the next github. https://github.com/AnalyticalGraphicsInc/cesium/tree/kml

build and run cesium.

However, I do not know. How can I specify, as in kml.

What should I write after the next?

var viewer = new Cesium.Viewer('cesiumContainer'); 
+6
source share
1 answer

There are several different ways to download KML data, the easiest way is to pass it the URL of the KML or KMZ file you want to read:

 var kmlDataSource = new Cesium.KmlDataSource(); kmlDataSource.loadUrl('path/to/kml/or/kmz'); viewer.dataSources.add(kmlDataSource); 

You cannot read local files this way, this path should be on the server, but if you want to drag and drop KML or KMZ files into your application, you can enable this by calling

 viewer.extend(Cesium.viewerDragDropMixin); 

Finally, about 30 seconds ago, I just added the ability to create a KmlDataSource and load the URL at the same time. If you sync to the branch head, you can do this on one line.

 viewer.dataSources.add(KmlDataSource.fromUrl('path/to/kml/or/kmz')); 
+12
source

Source: https://habr.com/ru/post/978136/


All Articles