Closed giswqs closed 2 months ago
I noticed that the add_control()
method does not work either.
from maplibre.ipywidget import MapWidget as Map
from maplibre.controls import NavigationControl, FullscreenControl
m = Map()
m.add_control(NavigationControl())
m
@giswqs In your example on top where you want to create your html output, you must import the Map
instead of the MapWidget
:
# Replace
# from maplibre.ipywidget import MapWidget as Map
# with
from maplibre import Map
I know using from maplibre import Map
works for creating HTML. One issue is that for users working with Jupyter notebook, how do they export the interactive map as an HTML file? The delimna is that you can see the interactive map, but you can't export it directly to HTML unless you go back to the notebook and change from maplibre.ipywidget import MapWidget as Map
to from maplibre import Map
Ah ok. You are right. This is not supported yet. I have to add this functionality.
Furthermore, I cannot reproduce your error with missing controls. Navigation control is added by default and if I add it once again, I got 2 of them :-)
I know using
from maplibre import Map
works for creating HTML. One issue is that for users working with Jupyter notebook, how do they export the interactive map as an HTML file? The delimna is that you can see the interactive map, but you can't export it directly to HTML unless you go back to the notebook and changefrom maplibre.ipywidget import MapWidget as Map
tofrom maplibre import Map
That would be great! It will make it easier to integrate maplibre with other web apps like streamlit and solara.
@giswqs Just forgot that it already works, you just need to activate the message queue:
from maplibre.ipywidget import MapWidget as Map
m = Map()
m.use_message_queue()
# ...
Nice! It indeed works. The caveat is that m.use_message_queue()
needs to be placed immediately after the map creatation. It won't work if placed after m.add_layer()
.
It generates the HTML file, but the data layers do not show up.