Cesium.CesiumWidget - Advantages?

I using Cesium in my application. My application shows billboards on the map accordingly with received positions.

I would like to know the difference between Cesium.Viewer and Cesium.CesiumWidget. Is it possible to create entities using Cesium Widget? What is the advantage of using the Cesium.CesiumWidget? Does it gives me the same functionality as Cesium.Viewer but without all the extra widgets (such as timeline)?

Thanks a lot!

Hello,

The CesiumWidget has very minimal functionality compared to the Viewer. It is responsible for creating the scene (including the globe, the atmosphere, the skybox, etc).

The Viewer is built on top of the CesiumWidget and adds a bunch of functionality. It uses the CesiumWidget to create the scene, then adds all of the other widgets. The Viewer also adds the entities datasource layer for adding things like billboards.

I would recommend using the Viewer and disabling any widgets you don’t think you need. However, you could use the CesiumWidget and add your own DatasourceDisplay like this:

var widget = new Cesium.CesiumWidget(‘cesiumContainer’);

var dataSourceDisplay = new Cesium.DataSourceDisplay({
scene : widget.scene,
dataSourceCollection : new Cesium.DataSourceCollection()
});

var entities = dataSourceDisplay.defaultDataSource.entities;
entities.add({
position : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
billboard :{
image : ‘…/images/Cesium_Logo_overlay.png’
}
});

widget.clock.onTick.addEventListener(function(clock) {
var time = clock.currentTime;
dataSourceDisplay.update(time);
});

``

This will display your billboards but doesn’t include any ability to click or zoom into them. The viewer is responsible for adding all of that enhanced functionality.

Best,

Hannah