testytesttest
testytesttest

Reputation: 13

How to add scrollbar to Python Folium popup?

How do you add a vertical scrollbar to a Python Folium map popup? I have too much information to display that the popup spans the entire screen currently.

Upvotes: 1

Views: 667

Answers (2)

Lily Cowper
Lily Cowper

Reputation: 3

If you're using geopandas.explore(), you can pass the maxHeight argument to poup_kwds. This will define a height and add a scrollbar automatically.

popup_kwds=dict(
    minWidth=500,
    maxWidth=700,
    maxHeight=400,
    style= 'background-opacity: 0.8;'
),

This works with geopandas.explore(), though I haven't tested it in a folium object.

Upvotes: 0

Riku
Riku

Reputation: 80

Use an iframe object and add it to the folium.popup object. Heres an example code:

import branca 

iframe = branca.element.IFrame(html='hello world' , width=500, height=400)

popup = folium.Popup(iframe, max_width=500 )

This example code automatically adds a scroll bar. Make sure your iFrame width matches the max width of the folium popup or else your scroll bar will not be within the bounds of the pop up object.

Upvotes: 1

Related Questions