Skip to content

Commit 9e9cf58

Browse files
Merge pull request #123 from eoda-dev/feature/draw-plugin-callbacks
Feature/draw plugin callbacks
2 parents 359240f + 114c945 commit 9e9cf58

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

docs/examples/mapbox_draw_plugin/app.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Shiny Express App
22

33
import json
4-
import webbrowser
54

65
from maplibre import Map, MapOptions, render_maplibregl
76
from maplibre.basemaps import Carto
@@ -65,13 +64,31 @@ def maplibre():
6564
@render.code
6665
def selected_features():
6766
obj = input.maplibre_draw_features_selected()
67+
obj["event"] = "selected"
6868
print(obj)
69-
return json.dumps(obj["features"], indent=2) if obj else "Pick some features!"
69+
return json.dumps(obj["features"], indent=2)
7070

7171

72-
if __name__ == "__main__":
73-
filename = "docs/examples/mapbox_draw_plugin/app.html"
74-
with open(filename, "w") as f:
75-
f.write(m.to_html())
72+
@render.code
73+
def on_features_created():
74+
obj = input.maplibre_draw_features_created()
75+
obj["event"] = "created"
76+
return json.dumps(obj, indent=2)
77+
78+
79+
@render.code
80+
def on_features_deleted():
81+
obj = input.maplibre_draw_features_deleted()
82+
obj["event"] = "deleted"
83+
return json.dumps(obj, indent=2)
7684

77-
webbrowser.open(filename)
85+
86+
@render.code
87+
def on_features_updated():
88+
obj = input.maplibre_draw_features_updated()
89+
obj["event"] = "updated"
90+
return json.dumps(obj, indent=2)
91+
92+
93+
if __name__ == "__main__":
94+
m.save(preview=True)

get-bindings.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
branch=${1:-dev}
3+
target_dir=maplibre/srcjs
4+
curl https://raw.githubusercontent.com/eoda-dev/maplibre-bindings/${branch}/py-bindings/pymaplibre.js -o $target_dir/pywidget.js
5+
curl https://raw.githubusercontent.com/eoda-dev/maplibre-bindings/${branch}/py-bindings/pymaplibre.css -o $target_dir/pywidget.css

maplibre/_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.2.6"
1+
__version__ = "0.2.8"
22
_shiny_output_class = "shiny-maplibregl-output"
33

44
# TODO: Remove from here

0 commit comments

Comments
 (0)