I'm trying to hide/show billboards based on the country they are in (this is selected in a controls box).
When I first add all of the billboards, they show up on the map fine.
When I try to set show to false, I can see (thank you developer tools) that the actual method in Billboard.js is being called.
However, the billboards are all still showing on the map.
If I put a breakpoint in the 'get' function, I see that it's called by updateObject, and the show value is true.
What is going on here?
Am I not doing this right?
I am accessing the billboards through the billboardcollection, through the primitives, through the viewer.
Thanks, and I hope you all can help!
I don’t know what’s causing the problem you’re seeing, but setting show = false should work.
Here’s a Sandcastle example that you can paste into http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var scene = viewer.scene;
var primitives = scene.primitives;
var logoUrl = ‘…/images/Cesium_Logo_overlay.png’;
var facilityUrl = ‘…/images/facility.gif’;
var billboards = scene.primitives.add(new Cesium.BillboardCollection());
billboards.add({
image : logoUrl,
position : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883)
});
billboards.add({
image : facilityUrl,
position : Cesium.Cartesian3.fromDegrees(-80.50, 35.14)
});
billboards.add({
image : facilityUrl,
position : Cesium.Cartesian3.fromDegrees(-80.12, 25.46)
});
var show = true;
Sandcastle.addToolbarButton(‘toggle show’, function() {
show = !show;
for (var i = 0; i < billboards.length; ++i) {
billboards.get(i).show = show;
}
});
Phew.. I tried out your code. After a lot of sweating and frustration, I compared my local Cesium source to the source folder on the Sandcastle.
Needless to say, my code didn't have the same functionality (I'm not sure how old it was).
I swapped out my source folder for 1.2 source folder, now it's all working correctly!
Thank you very much for your help, Scott!