Search code examples
cesiumjs

InfoBox is empty


My Cesium infobox is empty after I dynamically select an element.

This is how I'm selecting the element.

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())});
    }
  }

The entity is selected, the camera flys to it just fine, and the Cesium infobox displays the entity name in the title just fine, but doesn't display the description. If I select the entity by clicking on it, the box displays the description just fine.

I can't find anything to force the InfoBox to redraw, or see anything else I need to set for the InfoBox to update. So what am I missing?


  • I tried setting this.viewer.infoBox.viewModel.description but that didn't help either.

Solution

  • Apparently this was caused by selecting the entity while the map container was set to display: none. I was able to fix this by delaying the execution until focus returned to the map.