developmentseed / lonboard

A Python library for fast, interactive geospatial vector data visualization in Jupyter.
https://developmentseed.org/lonboard/latest/
MIT License
640 stars 33 forks source link

Adding a legend? #492

Open shriv opened 6 months ago

shriv commented 6 months ago

The examples on deck.gl don't have an integrated legend but I saw this suggestion on Pydeck and wonder if something similar would work with lonboard? There isn't an equivalent argument of description in the layers but it does look like there is a description card component in deck.gl Jupyter widget though not sure how to call it through lonboard..

kylebarron commented 6 months ago

Yes, a legend is desirable. But it's more likely for it to be built as a standalone widget (from python) than as a JavaScript component.

You can make a barebones legend by piecing together existing components from ipywidgets. A vbox of text and check boxes where checking a box toggles the visible flag on a layer

shriv commented 2 months ago

Hi @kylebarron. Just revisiting this issue as I do have pressing need for a colormap legend. I put together what I'm after with two screenshots below.. The simplest option is putting the output of cmap.mpl_colormap on to the map. With Folium, you can do this with branca. Can I take a similar approach?

image

kylebarron commented 2 months ago

We don't currently have a way to inject custom HTML onto the map, and so this isn't currently possible. I don't think we want to provide a custom colormap legend on the map itself.

As it is, you can render the colormap in a cell right before the map. Or you can use something like VBox to render the colormap just above the map, but in the same cell output: https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Layout.html#the-vbox-and-hbox-helpers