I am visualizing a geoJSON datasource in Cesium. I have tied it to a checkbox to modify the "show" property in order to turn it on and off after it is added to the viewer (not adding/removing the data source), however it seems like altering the "show" property alone does not actually hide or show the datasource. This is my function (handleclick is the function tied to the checkbox element):
function handleclick(cb) {
if (cb.checked === true) {
console.log(cb.id + " is checked")
for (var i in viewer.dataSources._dataSources) {
if ("chk_" + viewer.dataSources._dataSources[i]._name == cb.id) { //match checked box to datasource ID
viewer.dataSources._dataSources[i].show = new Cesium.ConstantProperty(true) //show layer?
}
}
} else {
console.log(cb.id + " is unchecked")
for (var i in viewer.dataSources._dataSources) {
if ("chk_" + viewer.dataSources._dataSources[i]._name == cb.id) {
viewer.dataSources._dataSources[i].show = new Cesium.ConstantProperty(false) //hide layer?
}
}
}
Do I need to update the viewer somehow after the "show" property (referenced at https://cesiumjs.org/Cesium/Build/Documentation/GeoJsonDataSource.html#show) is changed in order for the data to be hidden?