eodaGmbH / py-maplibregl

Python bindings for MapLibre GL JS
https://eodagmbh.github.io/py-maplibregl/
MIT License
27 stars 2 forks source link

The HTML doesn't display the exported object #41

Closed ambarja closed 2 months ago

ambarja commented 2 months ago

I would like to know if when exporting to an html file it can show the objects displayed as shown in the following screenshot. I have exported as html, but I can't visualizar the object (geopandas and raster tile).

Output in Google Colab

image

HTML output in the web browser

image

crazycapivara commented 2 months ago

@ambarja You need to activate the message queue to make it work when using the MapWidget object:

m = Map(map_options)
m.use_message_queue()
# ...

with open("app.html", "w") as f:
    f.write(m.to_html(style="height: 800px;"))

I will activate this by default in a future release :-)

ambarja commented 2 months ago

@ambarja You need to activate the message queue to make it work when using the MapWidget object:

m = Map(map_options)
m.use_message_queue()
# ...

with open("app.html", "w") as f:
    f.write(m.to_html(style="height: 800px;"))

I will activate this by default in a future release :-) @crazycapivara I have been used this code, but the result is the same :c

Google Colab

image

Web Browser

image

crazycapivara commented 2 months ago

You have to do this directly after initializing the map, otherwise it will not work!

ambarja commented 2 months ago

You have to do this directly after initializing the map, otherwise it will not work!

please Is possible to share an example ? 🙏😢

crazycapivara commented 2 months ago
from maplibre import Layer, LayerType, MapOptions
from maplibre.controls import FullscreenControl
from maplibre.ipywidget import MapWidget as Map
from maplibre.sources import GeoJSONSource

vancouver_blocks = GeoJSONSource(
    data="https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/geojson/vancouver-blocks.json",
)

map_options = MapOptions(
    center=(-123.1256, 49.24658),
    zoom=12,
    hash=True,
    pitch=35,
)

m = Map(map_options)
m.use_message_queue()
m.add_control(FullscreenControl())
m.add_layer(
    Layer(
        type=LayerType.LINE,
        source=vancouver_blocks,
        paint={"line-color": "white"},
    )
)

temp_file = "/tmp/pymaplibregl.html"

with open(temp_file, "w") as f:
    f.write(m.to_html(style="height: 800px;"))
ambarja commented 2 months ago

@crazycapivara thank you very much for the support! 🚀 ❤️