Skip to content

Commit

Permalink
Send picking object to Shiny
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed May 30, 2024
1 parent ff578b2 commit 48d2297
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
19 changes: 18 additions & 1 deletion docs/examples/deckgl_layer/app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Shiny Express App

import json

from maplibre import Map, MapOptions, render_maplibregl
from maplibre.basemaps import Carto
from maplibre.ui import use_deckgl

# from shiny import reactive
from shiny.express import input, render, ui

m = Map(
Expand All @@ -15,8 +19,10 @@
)
)

layer_id = "GridLayer"

deck_grid_layer = {
"@@type": "GridLayer",
"@@type": layer_id,
"id": "GridLayer",
"data": "https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-bike-parking.json",
"extruded": True,
Expand All @@ -39,6 +45,17 @@ def render_map():
return m


# @reactive.Effect
# @reactive.event(input.render_map_layer_GridLayer)
@render.code
def picking_object():
obj = input.render_map_layer_GridLayer()
print(obj)
# return json.dumps(obj, indent=2) if obj else "Pick a feature!"
# return f"{obj['count']}" if obj else "Pick a feature!"
return json.dumps(obj["points"], indent=2) if obj else "Pick a feature!"


if __name__ == "__main__":
with open("docs/examples/deckgl_layer/app.html", "w") as f:
f.write(m.to_html())
Loading

0 comments on commit 48d2297

Please sign in to comment.