Javascript 如何切换CZML实体的可见性属性(billboard.show)';什么是广告牌?

Javascript 如何切换CZML实体的可见性属性(billboard.show)';什么是广告牌?,javascript,cesium,Javascript,Cesium,根据Cesium API,要切换资产公告牌(或标签)的可见性,只需将billboard.show属性指定为false即可。当我尝试这样做时,铯会出错 An error occurred while rendering. Rendering has stopped. TypeError: undefined is not a function ... 来自cesium dev google组的一些示例代码用于打开/关闭公告牌可见性。如果尝试对CZML中的实体显示=false(本例不使用CZML

根据Cesium API,要切换资产公告牌(或标签)的可见性,只需将billboard.show属性指定为false即可。当我尝试这样做时,铯会出错

An error occurred while rendering.  Rendering has stopped.
TypeError: undefined is not a function
...
来自cesium dev google组的一些示例代码用于打开/关闭公告牌可见性。如果尝试对CZML中的实体显示=false(本例不使用CZML),则相同的代码不起作用

这是我试过的

var asset = loadedCZML.entities.getById(id);
asset.billboard.show = false; //Error!

(loadedCZML是一个
Cesium.CzmlDataSource

API文档中没有提到实体的
show
属性可能并不总是一个简单的布尔属性(如API所述)

使用
CzmlDataSource
实体
时,
show
属性被视为
TimeIntervalCollectionProperty
(至少我的CZML是这样)

Cesium中的所有属性都必须实现
getValue
功能,当您转到设置
show=false
时,该属性的设置程序无法将false应用于
TimeIntervalCollectionProperty
,而是将整个属性替换为一个简单的值
false

错误
undefined不是函数
是铯渲染调用试图调用
show
属性上的getValue()的结果。无论如何,解决方法很简单:

与此相反:

asset.billboard.show=false//错误

这样做:

asset.billboard.show = new Cesium.ConstantProperty(false);
PS:这适用于其他铯属性,请参见以下示例:

entity.billboard.image = pinBuilder.fromColor(Cesium.Color.CRIMSON, 48); //error

//do this instead
entity.billboard.image = new Cesium.ConstantProperty(pinBuilder.fromColor(Cesium.Color.CRIMSON, 48).toDataURL());