Is there some basic sample on how to toggle visibility of an entity? Or do you have to toggle visiblity of individual aspects (i.e. polygon/billboard) of an entity?
As an alternative, is there a way to remove individual entities/geojson features?
It would be nice if there was a getVisible() setVisible().
As of right now, you would have to toggle the individual pieces, but having a top level entity visibility flag is high on my to-do list. I wanted to do it for 1.7 but KML and forum questions took up all of my time. I definitely plan on adding it for 1.8.
The good news is there is a workaround using the entity.availability property. Here’s an example for Sandcastle.
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var blueBox = viewer.entities.add({
name : ‘Blue box’,
availability : new Cesium.TimeIntervalCollection(),
position: Cesium.Cartesian3.fromDegrees(-114.0, 40.0, 300000.0),
box : {
dimensions : new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
material : Cesium.Color.BLUE.withAlpha(0.6)
},
point : {
pixelSize: 10
}
});
blueBox.availability.addInterval(Cesium.Iso8601.MAXIMUM_INTERVAL);
Sandcastle.addToolbarButton(‘Toggle Visibility’, function(){
if(blueBox.availability.length !== 0){
blueBox.availability.removeAll();
}else{
blueBox.availability.addInterval(Cesium.Iso8601.MAXIMUM_INTERVAL);
}
});
viewer.zoomTo(viewer.entities);