首页 > 解决方案 > 信息框为空

问题描述

动态选择元素后,我的 Cesium 信息框为空。

这就是我选择元素的方式。

public selectById(id: string): void {
    console.log('selecting ' + id);
    if (id != null) {
      // this.viewer is Cesium.Viewer => https://cesiumjs.org/Cesium/Build/Documentation/Viewer.html?classFilter=viewer
      this.viewer.selectedEntity = this.viewer.entities.getById(id);
      // viewer.flyTo messes up the camera pitch
      this.viewer.camera.flyTo({destination: this.viewer.selectedEntity.position.getValue(Cesium.JulianDate.now())});
    }
  }

实体被选中,相机飞到它就好了,Cesium信息框在标题中显示实体名称就好了,但不显示描述。如果我通过单击选择实体,该框会很好地显示描述。

我找不到任何东西来强制 InfoBox 重绘,或者看到我需要为 InfoBox 更新设置的任何其他内容。那么我错过了什么?


标签: cesium

解决方案


显然,这是由于在地图容器设置为 时选择了实体造成的display: none。我可以通过延迟执行直到焦点返回地图来解决这个问题。


推荐阅读