From 359240f9835c841a4e2f6c14e9410486d513e2ee Mon Sep 17 00:00:00 2001 From: Stefan Kuethe Date: Tue, 17 Dec 2024 08:40:52 +0100 Subject: [PATCH] Update example --- docs/examples/getting_started/shiny_express.py | 11 ++++++++++- pyproject.toml | 12 +++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/examples/getting_started/shiny_express.py b/docs/examples/getting_started/shiny_express.py index 36b84c6..c619a21 100644 --- a/docs/examples/getting_started/shiny_express.py +++ b/docs/examples/getting_started/shiny_express.py @@ -1,8 +1,10 @@ import json +from shiny import reactive from shiny.express import input, render, ui -from maplibre import Map, MapOptions, render_maplibregl +from maplibre import Map, MapContext, MapOptions, render_maplibregl +from maplibre.controls import Marker ui.h1("My awesome MapLibre map") @@ -26,3 +28,10 @@ def coords(): @render.code def view_state(): return json.dumps(input.mapgl_view_state(), indent=2) + + +@reactive.Effect +@reactive.event(input.mapgl_clicked) +async def set_marker(): + async with MapContext("mapgl") as m: + m.add_marker(Marker(lng_lat=input.mapgl_clicked()["coords"].values())) diff --git a/pyproject.toml b/pyproject.toml index 38d9351..70e3e5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,9 +5,7 @@ description = "Python bindings for MapLibre GL JS" authors = ["Stefan Kuethe "] readme = "README.md" license = "MIT" -include = [ - { path = "srcjs", format = ["sdist", "wheel"] } -] +include = [{ path = "srcjs", format = ["sdist", "wheel"] }] [tool.poetry.dependencies] python = ">=3.9,<4" @@ -16,8 +14,8 @@ htmltools = ">=0.5.1" jinja2 = ">=3.1.3" pydantic = ">=2.5.3" anywidget = ">=0.9.0" -pandas = {version = "^2.1.4", optional = true} -geopandas = {version = "^0.14.2", optional = true} +pandas = { version = "^2.1.4", optional = true } +geopandas = { version = "^0.14.2", optional = true } branca = "*" [tool.poetry.group.dev.dependencies] @@ -25,7 +23,7 @@ black = "^24.4.2" isort = "^5.13.2" pytest = "^7.4.3" mkdocs = "^1.5.3" -mkdocstrings = {extras = ["python"], version = "^0.24.0"} +mkdocstrings = { extras = ["python"], version = "^0.24.0" } mkdocs-material = "^9.5.3" geopandas = "^0.14.2" pmtiles = "*" @@ -34,7 +32,7 @@ pmtiles = "*" all = ["pandas", "geopandas"] [tool.black] -line-lenght = 120 +line-length = 120 [build-system] requires = ["poetry-core"]