diff --git a/docs/examples/mapbox_draw_plugin/app.html b/docs/examples/mapbox_draw_plugin/app.html
new file mode 100644
index 00000000..4e512eb9
--- /dev/null
+++ b/docs/examples/mapbox_draw_plugin/app.html
@@ -0,0 +1,33 @@
+
+
+
+
My Awesome Map
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/examples/mapbox_draw_plugin/app.py b/docs/examples/mapbox_draw_plugin/app.py
index 50c2a5fb..ec3c5642 100644
--- a/docs/examples/mapbox_draw_plugin/app.py
+++ b/docs/examples/mapbox_draw_plugin/app.py
@@ -1,6 +1,7 @@
# Shiny Express App
import json
+import webbrowser
from maplibre import Map, MapOptions, render_maplibregl
from maplibre.basemaps import Carto
@@ -48,5 +49,8 @@ def selected_features():
if __name__ == "__main__":
- with open("docs/examples/mapbox_draw_plugin/app.html", "w") as f:
+ filename = "docs/examples/mapbox_draw_plugin/app.html"
+ with open(filename, "w") as f:
f.write(m.to_html())
+
+ webbrowser.open(filename)
diff --git a/maplibre/map.py b/maplibre/map.py
index 316930a7..7d7f8c4b 100644
--- a/maplibre/map.py
+++ b/maplibre/map.py
@@ -258,10 +258,14 @@ def to_html(self, title: str = "My Awesome Map", **kwargs) -> str:
"""
js_lib = read_internal_file("srcjs", "index.js")
js_snippet = Template(js_template).render(data=json.dumps(self.to_dict()))
+ headers = []
+
+ # Deck.GL headers
add_deckgl_headers = "addDeckOverlay" in [
item[0] for item in self._message_queue
]
- headers = (
+ # TODO: Set version in constants
+ deckgl_headers = (
[
'',
'',
@@ -269,8 +273,26 @@ def to_html(self, title: str = "My Awesome Map", **kwargs) -> str:
if add_deckgl_headers
else []
)
+
+ # Mapbox Draw headers
+ add_mapbox_draw_headers = "addMapboxDraw" in [
+ item[0] for item in self._message_queue
+ ]
+ # TODO: Set version in constants
+ mapbox_draw_headers = (
+ [
+ '',
+ "",
+ ]
+ if add_mapbox_draw_headers
+ else []
+ )
+
output = Template(html_template).render(
- js="\n".join([js_lib, js_snippet]), title=title, headers=headers, **kwargs
+ js="\n".join([js_lib, js_snippet]),
+ title=title,
+ headers=headers + deckgl_headers + mapbox_draw_headers,
+ **kwargs,
)
return output