Viewer vs. Widget

What is the difference between the 2 and when should I use which.

I noticed Widget doesn’t come with the time toolbar(which I don’t need) Or the Help and view changing toolbar(thats in the upper right hand corner) (which I would Like to have) How do I add that to the Widget.

More often than not you’ll want to use the Viewer, as you can disable the extra widgets that you don’t need. The Viewer object contains the Widget among other useful CesiumWidgets, such as Help and the SceneModePicker.

As a concrete example of what Alex is talking about, you can create a Viewer instance without the timeline or animation controls using the below code:

var viewer = new Cesium.Viewer(‘cesiumContainer’, {

timeline: false,

animation: false

});

If you still want to use the CesiumWidget directly, that’s fine too; but we don’t think it’s worth it. You can start with the Viewer implementation in these two files and then cut out what you don’t want/need.

https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Widgets/Viewer/Viewer.js

https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Widgets/Viewer/Viewer.css

Source of the question. I’m using the DrawHelper Tool and it is working on the Widget I tried switching to the Viewer and it doesn’t work. But I still want the view changer that is up in the Right hand corner for my project.

So did you find a way to use DrawHelper with the Viewer? Viewer.cesiumWidget doesn't seem to work.

It comes down entirely to convenience. CesiumWidget is a bare-bones initialization of the engine with no GUI loaded, whereas CesiumViewer includes all of the UI features and you need to deselect the ones you don’t want.

I believe most Geospatial applications will probably be using the Viewer, disabling the few UI components they do not want. Whereas more advanced integrated web applications that are combining Cesium with other systems would want to use the Widget so they can lock down and integrate controls as much as possible.

I’ve got a basic example of the DrawHelper on my Viewer at http://jsfiddle.net/bartyhoho/pzuarnt3/2/ The toolbar images don’t display because those would be local to your server. I can switch scene modes and it seems to work as expected, although there is some flickering in the Columbus view.

Bart