Skip to content

Docs: show feature info in a fixed box - #2359

Open
KhadeerBasha1232 wants to merge 1 commit into
python-visualization:mainfrom
KhadeerBasha1232:docs-pinned-info-box
Open

KhadeerBasha1232 wants to merge 1 commit into
python-visualization:mainfrom
KhadeerBasha1232:docs-pinned-info-box

Conversation

@KhadeerBasha1232

Copy link
Copy Markdown
Contributor

Docs: show feature info in a fixed box

Closes #1545

The problem

#1545 asks how to show the information of a hovered feature at a fixed spot
on the map, like the info box in Leaflet's
interactive choropleth tutorial.
GeoJsonTooltip always follows the mouse, and the docs don't show another way.

The change

A new page in the advanced guide, Show feature info in a fixed box
(docs/advanced_guide/info_box.md). It builds the US unemployment map from
the folium example data and shows how to:

  • write a small InfoBox MacroElement that creates a Leaflet control at a
    chosen position, with fields / aliases like GeoJsonTooltip;
  • update it from GeoJson(on_each_feature=...), passing the box to JsCode
    as a parameter so %(info)s becomes its Javascript name.

It only uses existing folium features, so there are no library changes. The
box fills in its text with textContent, so property values are never parsed
as HTML.

Depends on #2358

on_each_feature crashes on the current main and in v1.0.0. #2358 fixes
that. Until it's merged this example renders without the states, the same
as the existing on_each_feature user guide page.

How I checked it

I ran the page's code cells and opened the result in a browser, with #2358
applied:

  • All 50 states are drawn and colored, with no console errors.
  • Before any hover, the box in the top right shows the title and
    "Hover over a state".
  • Hovering Texas highlights it, and the box shows
    State: Texas / Unemployment (%): 6.4.
  • Moving the mouse off the states resets the box to the placeholder.

Closes python-visualization#1545

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was previously deployed

1 inactive deployment
pypi — 107d4c44 Deployed Nov 19, 2026 by KhadeerBasha1232 via packages #2113
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display GeoJsonTooltip at a pinned position

1 participant

⌂ Proxy