Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Davide-sd opened this issue Mar 28, 2025 · 0 comments

Comments

@Davide-sd
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants