Skip to content

Commit

Permalink
Add mapbox draw func
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed Jun 25, 2024
1 parent bc37938 commit d02bf1d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
12 changes: 8 additions & 4 deletions docs/examples/mapbox_draw_plugin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

from maplibre import Map, MapOptions, render_maplibregl
from maplibre.basemaps import Carto
from maplibre.controls import ControlPosition, NavigationControl
from maplibre.controls import ControlPosition, NavigationControl, ScaleControl
from maplibre.plugins import add_mapbox_draw
from maplibre.ui import use_mapboxgl_draw

# from shiny import reactive
Expand Down Expand Up @@ -48,9 +49,12 @@
"trash": True,
},
}
m.add_call(
"addMapboxDraw", draw_options, ControlPosition.TOP_LEFT.value, geojson_feature
)
add_mapbox_draw(m, geojson=geojson_feature, position=ControlPosition.BOTTOM_LEFT)
m.add_control(ScaleControl(), ControlPosition.BOTTOM_RIGHT)

# m.add_call(
# "addMapboxDraw", draw_options, ControlPosition.TOP_LEFT.value, geojson_feature
# )

# Shiny Express
use_mapboxgl_draw()
Expand Down
15 changes: 15 additions & 0 deletions maplibre/plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import annotations

from .controls import ControlPosition
from .map import Map


def add_mapbox_draw(
map_: Map,
options: dict = None,
position: str | ControlPosition = ControlPosition.TOP_LEFT,
geojson: dict = None,
) -> None:
map_.add_call(
"addMapboxDraw", options or {}, ControlPosition(position).value, geojson
)

0 comments on commit d02bf1d

Please sign in to comment.