Hi Matthew,
this polygon.kml is only for a test but I have already visualised it on google earth.
this is my code:
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('pathToMyPolygon').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('id1');
var poly_2=myDataSource.entities.getById('id2');
var poly_3=myDataSource.entities.getById('id3');
var poly_4=myDataSource.entities.getById('id4');
document.getElementById('btn1').addEventListener('click',function(){
poly_1.show=false;
});
document.getElementById('btn2').addEventListener('click',function(){
poly_2.show=false;
});
document.getElementById('btn3').addEventListener('click',function(){
poly_3.show=false;
});
document.getElementById('btn4').addEventListener('click',function(){
poly_4.show=false;
});
I thought that if I change the property of each polygon container, the polygon itself will be hidden.
This is what I did and I can't find a way to hidden/show these polygons in one file