Cesiumjs – Show and hide multiple entity/labels

How can i toggle multiple labels/entities ?

phpmind-cesiumjs-show-hide

var viewer = new Cesium.Viewer('cesiumContainer', { infoBox : false });
var entities = viewer.entities;

var labels = entities.add(new Cesium.Entity());

var longitude = - 106;
for (var i = 0; i < 5; ++i) {
    entities.add({
        parent : labels,
        position : Cesium.Cartesian3.fromDegrees(longitude, 45.0),
        label : {
            text : i.toString()
        }
    });
    longitude++;
}

viewer.zoomTo(viewer.entities);

Sandcastle.addToolbarButton('Toggle Labels', function(){
    labels.show = !labels.show;
});
Share

Leave a Reply

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