I am seeing an issue with setting .show on entities that are part of a CompositeEntityCollection. Whenever I set .show=false on all my entities, some will be hidden properly it seems that polygons or polylines will remain onscreen. My goal is to allow the user to “hide” certain polygon entities. I made a sample Sandcastle app that exhibits my problem.
Can someone help me figure out what I’m doing wrong? Thanks!
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var dataSource;
var entityCollComposite;
Sandcastle.addToolbarButton(‘HIDE ALL ENTITIES’, function() {
var entities = dataSource.entities;
for (var i = 0; i < entities.values.length; i++) {
entities.values[i].show=false;
}
});
Sandcastle.addToolbarButton(‘SHOW ALL ENTITIES’, function() {
var entities = dataSource.entities;
for (var i = 0; i < entities.values.length; i++) {
entities.values[i].show=true;
}
});
Sandcastle.addToolbarMenu([{
text : ‘KML - Global Science Facilities’,
onselect : function() {
entityCollComposite = new Cesium.CompositeEntityCollection();
dataSource = new Cesium.KmlDataSource();
dataSource.load(’…/…/SampleData/kml/gdpPerCapita2008.kmz’);
entityCollComposite.addCollection(dataSource.entities);
viewer.homeButton.viewModel.command();
viewer.dataSources.add(dataSource);
}
}], ‘toolbar’);