Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Allow standalone export #53

Open
astrojuanlu opened this issue Dec 3, 2019 · 7 comments
Open

Allow standalone export #53

astrojuanlu opened this issue Dec 3, 2019 · 7 comments

Comments

@astrojuanlu
Copy link
Member

No description provided.

@astrojuanlu
Copy link
Member Author

I think this means producing complete HTML that does not need embedding anywhere else.

@lalligagger
Copy link

lalligagger commented Sep 7, 2022

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?

@astrojuanlu
Copy link
Member Author

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:

czml3/src/czml3/widget.py

Lines 97 to 103 in 46b4342

def to_html(self, widget_height="400px"):
return CESIUM_TPL.format(
cesium_version=self.cesium_version,
script=self.build_script(),
container_id=self._container_id,
widget_height=widget_height,
)

@lalligagger
Copy link

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

@astrojuanlu
Copy link
Member Author

What exactly didn't work, or what errors did you observe? Would be useful to know so we can try to address them.

@lalligagger
Copy link

I added your suggested tags to beginning/ end of to_html output and saved as .html but nothing renders in that case.

@Xenon130
Copy link

Xenon130 commented Apr 5, 2023

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants