GithubHelp home page GithubHelp logo

Allow standalone export about czml3 HOT 7 OPEN

poliastro avatar poliastro commented on May 27, 2024
Allow standalone export

from czml3.

Comments (7)

Xenon130 avatar Xenon130 commented on May 27, 2024 2

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)

from czml3.

lalligagger avatar lalligagger commented on May 27, 2024 1

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

from czml3.

astrojuanlu avatar astrojuanlu commented on May 27, 2024

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

from czml3.

lalligagger avatar lalligagger commented on May 27, 2024

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?

from czml3.

astrojuanlu avatar astrojuanlu commented on May 27, 2024

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,
)

from czml3.

lalligagger avatar lalligagger commented on May 27, 2024

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

from czml3.

astrojuanlu avatar astrojuanlu commented on May 27, 2024

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

from czml3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.