Error when trying to add entities to Cesium.CesiumWidget


I am trying to add an entity in a Cesium.CesiumWidget, through its entities collection but I get the following error:

TypeError: Cannot read property 'add' of undefined

I am actually trying to reproduce the Camera demo from Sandcastle but instead of using the standard Viewer, I try to use the Widget Viewer. Below is my src code:

var viewer = new cesium.CesiumWidget('cesiumContainer');

var west = -77.0;
var south = 38.0;
var east = -72.0;
var north = 42.0;

var rectangle = Cesium.Rectangle.fromDegrees(west, south, east, north);{
        destination: rectangle

// Show the rectangle. Not required; just for show.
        rectangle : {
            coordinates : rectangle,
            fill : false,
            outline : true,
            outlineColor : Cesium.Color.WHITE

I use:

- Cesium 1.19
- Windows 10 Enterprise
- Google Chrome 49.0.2623.87 m


This code is meant to use the Viewer, not the CesiumWidget.

Replace the first line of your example with

var viewer = new Cesium.Viewer(‘cesiumContainer’);




Isn't it possible to add entities using the widget in any way?

Hi Hannah,

I finally tried to add some entities as stated in this thread.!searchin/cesium-dev/CesiumWidget/cesium-dev/2MQk1VNecWs/dgBlwqdABgAJ

Thank you for your reply!