cesiumjs – How to access folder from KML file and parse.

How to access from KML file and parse to make folder structure.
phpmind-cesiumjs-access-folder-from-kml


var viewer = new Cesium.Viewer('cesiumContainer', {
    timeline : true,
    animation : false,
    homeButton : false,
    screenModePicker : false,
    navigationHelpButton : false,
    baseLayerPicker : false,
    geocoder : false,
    sceneMode : Cesium.SceneMode.SCENE3D
});
var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({
    url : '//assets.agi.com/stk-terrain/world',
    requestWaterMask : true,
    requestVertexNormals : true
});
viewer.terrainProvider = cesiumTerrainProviderMeshes;
var ds = new Cesium.KmlDataSource();
var myDataSource;
ds.load('../../SampleData/polygon.kml').then(function(dataSource) {
    viewer.dataSources.add(dataSource);
    myDataSource = dataSource;
    //I gave an ID to folder containing each polygon then I took it by getById method
    var poly_1 = myDataSource.entities.getById('poly_1');
    var poly_2 = myDataSource.entities.getById('poly_2');
    var poly_3 = myDataSource.entities.getById('poly_3');
    var poly_4 = myDataSource.entities.getById('poly_4');

    Sandcastle.addToolbarButton('click1',function(){
        poly_1.show=false;
    });
    Sandcastle.addToolbarButton('click2',function(){
        poly_2.show=false;
    });
    Sandcastle.addToolbarButton('click3',function(){
        poly_3.show=false;
    });
    Sandcastle.addToolbarButton('click4',function(){
        poly_4.show=false;
    });
});

KML file

Share

Leave a Reply

Your email address will not be published. Required fields are marked *