Allow standalone export
I think this means producing complete HTML that does not need embedding anywhere else.
Hi @astrojuanlu! Is there currently any good way to use the CZMLWidget HTML representation outside of a notebook, e.g. embedded within some template page?
Hi @lalligagger! If I recall correctly, this widget does not (yet) have any jupyter-specific code, it's just a blob of HTML. The only thing missing is <html>, <head>, and <body>, but maybe this is perfect for what you need.
Have a look at the to_html method:
https://github.com/poliastro/czml3/blob/46b434214b40dee14fbe2d0d74baba90b44b7ba4/src/czml3/widget.py#L97-L103
Ok, I haven't been able to get standalone html working but a mashup of the extractor and the approach taken below has me running in a dash app!
https://community.plotly.com/t/adding-cesium-app-to-plotly-dash/48336
What exactly didn't work, or what errors did you observe? Would be useful to know so we can try to address them.
I added your suggested tags to beginning/ end of to_html output and saved as .html but nothing renders in that case.
The existing "to_html" function actually works, but you need to load RequireJS in the html page you want to hold the resulting widget. For example:
from czml3.examples import simple
from czml3.widget import CZMLWidget
view = CZMLWidget(simple)
html = view.to_html()
page = f"""<!DOCTYPE html>
<html>
<head>
<script src="http://requirejs.org/docs/release/2.3.6/comments/require.js"></script>
</head>
<body>
<!-- CZMLWidget -->
{html}
</body>
</html>
"""
# save to file
with open("CesiumJS.html", "w") as file:
file.write(page)