jupyter-widgets / ipyleaflet

A Jupyter - Leaflet.js bridge
https://ipyleaflet.readthedocs.io
MIT License
1.47k stars 358 forks source link

Popups with geodataframe/`GeoData`/`GeoJSON` #837

Open xoolive opened 3 years ago

xoolive commented 3 years ago

It would be great to be able to parametrize popups so that elements added with a GeoData are clickable and properties associated with each shape can be accessed.

Maybe it's not the best, but I would imagine a basic api along the following:

GeoData(geo_dataframe=..., popup: str | List[str] = single_or_list_of_features)
giswqs commented 3 years ago

This would be a nice feature to add. Currently, it seems only Marker has a popup attribute. My workaround in leafmap is to use an HTML widget and update it with GeoJSON on_hover and on_click.

https://leafmap.org/notebooks/10_add_vector/

https://user-images.githubusercontent.com/5016453/121617468-facf5780-ca32-11eb-9f48-2fd63b810199.mp4

giswqs commented 3 years ago

I just added a add_point_layer() function to leafmap that can display popup attributes with a single line of code. See notebook example https://leafmap.org/notebooks/18_point_layer.