eodaGmbH / py-maplibregl

Python bindings for MapLibre GL JS
https://eodagmbh.github.io/py-maplibregl/
MIT License
27 stars 2 forks source link

Tooltip Question #52

Closed diehl closed 1 month ago

diehl commented 1 month ago

Hi Stefan,

I wanted to see if the following approach to rendering geometry attributes in a tooltip might be possible. Imagine we have a vector layer where each geometry has a single attribute that is a geometry ID. As the user hovers the mouse over geometries, I'm wondering if it is possible to fetch geometry attributes from a key-value store based on the ID and render them in the tooltip. Said another way, must the geometry attributes be embedded in the source data in order to be rendered in a tooltip?

Chris

crazycapivara commented 1 month ago

Hi Chris,

the properties of the hovered feature are passed to the tooltip rendering function. Therefore, only these can be used in a tooltip. But if you are in a Shiny app, you can listen to the properties when a feature is hovered. So you can use the ID or something else to fetch more attributes from somewhere else. Then you can display this information in a Shiny text element above or below or beside the map. But at the moment it is not possible to set a tooltip that way. I would need to make a mapping to set and remove popups via the MapContext.

Stefan

diehl commented 1 month ago

Hi Stefan,

Thank you for this timely clarification. This all makes sense. For certain exploration, I find the tooltip is indispensable. Having to look to another part of the screen while dithering the mouse pointer over neighboring geometries creates unacceptable cognitive friction I find. In addition, if the update of the attribute panel off to the side is contingent on a hover action, it slows down the process of exploration. The tooltip is preferable since the update of the information is immediate once the mouse pointer moves from one geometry to another.

All this to say, I guess, that I'd be super stoked to have a capability to bring arbitrary attributes into the mix that are not embedded in the source data. ;-)

Chris