How to render a viewer in a Jupyter notebook¶
How-to. Target: a live globe inside a notebook cell, with buttons to control the clock and receive click events.
The widget runs CesiumJS in the notebook from the CDN — notebooks have no
local server — and mirrors the runtime control API of show(). There is no
HTTP server to start or stop.
Prefer a plain browser window?
The same control API works over show()'s local server — see
How to control a live viewer.
1. Install the widget extra¶
2. Build a viewer and turn it into a widget¶
import cesiumkit
viewer = cesiumkit.Viewer()
viewer.add_entity(
cesiumkit.Entity(
name="NYC",
position=cesiumkit.Cartesian3.from_degrees(-74.006, 40.7128, 400),
)
)
widget = viewer.to_widget()
widget # display this cell to render the globe
3. Drive the clock and read it back¶
widget.set_time("2026-07-14T18:00:00Z")
widget.set_multiplier(60) # seconds of simulation per real second
widget.animate(True)
current = widget.get_current_time() # reads the live clock from the browser
4. React to clicks and save screenshots¶
API reference¶
-
widget ¶Jupyter widget integration (anywidget).
CesiumKitWidgetrenders a Viewer inside a notebook with a live bidirectional command channel: Python sends commands (clock, selection, screenshot) over the comm, the widget's JavaScript evaluates them againstwindow.viewerand sends results/click events back.Requires the
[widget]extra (anywidget). Import lazily:from cesiumkit.widget import CesiumKitWidget widget = viewer.to_widget()Classes:
Name Description CesiumKitWidgetA Jupyter widget rendering a cesiumkit Viewer with live control.
CesiumKitWidget ¶Bases:
AnyWidgetA Jupyter widget rendering a cesiumkit Viewer with live control.
Methods:
Name Description set_timeSet the clock to an ISO-8601 time.
set_multiplierSet the clock multiplier (simulation speed).
animateStart or stop the clock animation.
get_current_timeReturn the current clock time as ISO-8601.
on_clickRegister a callback invoked with the clicked entity id (or None).
screenshotSave a PNG screenshot of the live canvas.
closeClose the widget and fail any commands still awaiting a browser reply.