bokeh icon indicating copy to clipboard operation
bokeh copied to clipboard

Hiding map tiles attribution when multiple tiles renderer are added to the plot

Open Davide-sd opened this issue 9 months ago • 2 comments

Problem description

Consider the following application, in which the user can choose a tile provider. The logic is implement with Javascript to make this process on the client rather than spending server resources.

All tiles renderers are added when the figure is created, but only the selected tile renderer is visible. However, the attribution box on the figure shows attributions for all tile renderers, even the ones that are currently hidden.

import panel as pn
from bokeh.plotting import figure
pn.extension()

map_selector = pn.widgets.Select(
    name="Tiles",
    options=[
        "OpenStreetMap.Mapnik",
        "OpenTopoMap",
        "CartoDB.Positron",
        "CartoDB.Voyager",
        "Esri.WorldImagery",
    ]
)

p = figure(
    x_axis_type="mercator", 
    y_axis_type="mercator",
    x_range=(1289584.505648815, 1489584.505648815),
    y_range=(5045162.214307019, 5245162.214307019),
)
p.grid.visible = False
p.match_aspect = True

tiles_renderers = {}
for k in map_selector.options:
    tiles_renderers[k] = p.add_tile(k, retina=True)
    tiles_renderers[k].visible = (k == map_selector.value)

map_selector.jscallback(
    args={
        "tiles_renderers": tiles_renderers,
        "map_selector": map_selector,
    },
    value="""
for (const [key, value] of Object.entries(tiles_renderers)) {
  value.visible = (key === map_selector.value)
}
""")

pn.Row(map_selector, p)

Image

Feature description

It would be nice if bokehjs would be able to filter the renderers and add an attribution only for the ones that are actually visible.

Potential alternatives

No one.

Additional information

No response

Davide-sd avatar Mar 28 '25 22:03 Davide-sd

Hi @mattpap I wanted to know if this issue is still there or already resolved? If not resolved can I start working on it?

Arup3201 avatar Jun 10 '25 11:06 Arup3201

I wanted to know if this issue is still there or already resolved? If not resolved can I start working on it?

The issue is open and there are no associated PRs, then it isn't resolved. There are no assigned people to this issue, or any other indications someone is working or is supposed to work on this (like within a specific grant), then the issue is a valid candidate for working on. This issue is indeed a good candidate to start contributing to bokeh.

mattpap avatar Jun 10 '25 11:06 mattpap

Hi @mattpap after spending some time on the bokeh codebase and this issue, I have understood some parts and wanted to verify them with you. Here, the expected behavior is not to show those tile provider names at the bottom, right?

Even though setting the visible attribute of the some tile providers, all of them are visible. So, I need to update the way attributes are collected and rendered on the UI at bokehJS. In that, I also need to add another check for visible property value, if it is true then show the tile provider name at bottom, otherwise don't show it.

Is this what I need to do in this issue?

Arup3201 avatar Jun 20 '25 10:06 Arup3201