-
Hello, I have a geodataframe composed on many polygons. I would like to create an interactive map that when the user clicks on a polygon, a specific spreadsheet data file corresponding to that polygon, is loaded as a pandas dataframe. From there a graph of that dataframe can be shown on screen, or the user can choose to download that spreadsheet file. Could someone direct me to how leafmap can be used to accomplish something like this? Or if its not possible is there some other recommended solution? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The Line 2740 in 98077c0 def handle_click(**kwargs):
if kwargs.get('type') == 'click':
latlon = kwargs.get('coordinates')
geometry = Point(latlon[::-1])
selected = m.gdf[m.gdf.intersects(geometry)]
setattr(m, 'zoom_to_layer', False)
if len(selected) > 0:
catalog_ids = selected['catalog_id'].values.tolist()
if len(catalog_ids) > 1:
image.options = catalog_ids
image.value = catalog_ids[0]
else:
image.value = None
m.on_interaction(handle_click) Try out this web app. When clicking on the map, it will display the corresponding image tile. https://huggingface.co/spaces/giswqs/solara-maxar solara-maxar.mp4 |
Beta Was this translation helpful? Give feedback.
The
Map.on_interaction()
method can do that.leafmap/leafmap/toolbar.py
Line 2740 in 98077c0
https://github.com/opengeos/solara-maxar/blob/0c0e9ecee335eb6b1ec1191b67261a5d6320c216/pages/01_morocco.py#L190