Skip to content

Commit fcea980

Browse files
Merge pull request #150 from eoda-dev/nuayge-shiny-module
Nuayge shiny module
2 parents 818e514 + fc14fa2 commit fcea980

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog for MapLibre for Python
22

3+
## maplibre v0.3.5
4+
5+
* Fix #142 (thx to @nuayge)
6+
37
## maplibre v0.3.4
48

59
* Fix pydantic list bug in `basemaps.py` and `light.py` (#144)

examples/shiny/app_with_modules.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from shiny import App, ui, module, reactive
2+
from maplibre import output_maplibregl, render_maplibregl, Map, MapContext
3+
4+
5+
@module.ui
6+
def shiny_module_ui():
7+
return ui.page_fluid(
8+
ui.panel_title("MapLibre"),
9+
ui.input_action_button("btn", "Click"),
10+
output_maplibregl("mapgl", height=600),
11+
)
12+
13+
14+
@module.server
15+
def shiny_module_server(input, output, session):
16+
17+
@render_maplibregl
18+
def mapgl():
19+
m = Map()
20+
return m
21+
22+
@reactive.effect
23+
@reactive.event(input.btn)
24+
async def move_it():
25+
async with MapContext("mapgl") as m:
26+
m.add_call("flyTo", {"center": [-1.66928, 48.1024159], "zoom": 15})
27+
28+
29+
app_ui = ui.page_fluid(shiny_module_ui("shiny_mod"))
30+
31+
32+
def server(input, output, session):
33+
shiny_module_server("shiny_mod")
34+
35+
36+
app = App(app_ui, server)
37+

maplibre/mapcontext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class MapContext(Map):
1818
"""
1919

2020
def __init__(self, id: str, session: Session = None) -> None:
21-
self.id = id
2221
self._session = require_active_session(session)
22+
self.id = id if self._session.ns == "" else f"{self._session.ns}-{id}"
2323
self.map_options = {}
2424
self._message_queue = []
2525

maplibre/shiny/mapcontext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class MapContext(Map):
2626
"""
2727

2828
def __init__(self, id: str, session: Session = None) -> None:
29-
self.id = id
3029
self._session = require_active_session(session)
30+
self.id = id if self._session.ns == "" else f"{self._session.ns}-{id}"
3131
self.map_options = dict()
3232
self._message_queue = list()
3333

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "maplibre"
3-
version = "0.3.4"
3+
version = "0.3.5"
44
description = "Python bindings for MapLibre GL JS"
55
authors = ["Stefan Kuethe <stefan.kuethe@eoda.de>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)