drawing polygons question


I'm new to the Cesium API and am trying to learn the easiest way to add polygons to the Cesium globe. I have looked extensively at the sandcastle demos on the Cesium site, but still am struggling to understand something. I started using and modifying the jQuery UI demo page, and then tried to add a polygon to it. However, it didn't work and upon further examination of your polygon example it looks like there are two objects (CesiumViewerWidget and Sandcastle object) that are not present in the jQuery UI demo page. Do both of these objects need to be used in order to overlay a polygon on the Cesium globe, or is it possible to modify the jQuery UI page to draw polygons without these two objects?

Any help would be greatly appreciated.


- Paul

Hi Paul,

In the jQuery UI example, add the following code under Line 39:

var polygon = new Cesium.Polygon();


Cesium.Cartographic.fromDegrees(-72.0, 40.0),

Cesium.Cartographic.fromDegrees(-70.0, 35.0),

Cesium.Cartographic.fromDegrees(-75.0, 30.0),

Cesium.Cartographic.fromDegrees(-70.0, 30.0),

Cesium.Cartographic.fromDegrees(-68.0, 40.0)



This creates a polygon, gives it the boundary positions, and then adds it to the list of primitives so it will be drawn.

CesiumViewerWidget is a widget we wrote for using Cesium with Dojo. Sandcastle is an object used in the Sandcastle editor, and is not part of Cesium (however, it is available in the jQuery UI example when I try). We know this is a bit confusing, but we are working on simplifying it.