I’m using JupyterLab 1.0, running inside a docker container for development. Try this as a hello world, running it inside one step. It’s a bit hacky, admittedly.
def cesium_html():
return \
"""
<iframe style="width: 1024px; height: 768px; overflow:hidden; border: 0px; margin: 0px" scrolling="no"
frameborder="0" marginheight="0" marginwidth="0" sandbox="allow-scripts" srcdoc='
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<script src="https://cesiumjs.org/releases/1.60/Build/Cesium/Cesium.js"></script>
<link href="https://cesiumjs.org/releases/1.60/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
<div id="cesiumContainer" style="width: 1024px; height:768px"></div>
<script>
//Cesium.IondefaultAccessToken = "your_access_token";
var viewer = new Cesium.Viewer("cesiumContainer");
</script>
</body>
</html>
'></iframe>
"""
import IPython.display
IPython.display.HTML(cesium_html())
You should see a cesium globe appear. The iframe was necessary to avoid leaking the web worker threads, which will eventually cripple your computer ![]()
In use case, I’m using CZML, with the czml3 python library, to create and render my data inside cesium, though I’ll probably switch to native javascript soon as I need more flexibility.
I’m not a Jupyter expert, so there is probably a better way. I expect that the right way to do this is a formal “widget”, something like https://github.com/petrushy/CesiumWidget/blob/master/CesiumWidget/cesiumwidget.py, but it’s a bit out of date and I haven’t tried it. There’s also https://github.com/sinhrks/cesiumpy/tree/master/cesiumpy but it also is a bit neglected and didn’t work for me, so I ended up doing my own thing.