3

I recently started working with folium which is a bit web developer oriented and I'm not. So I created a map and injected a title onto it, like this:

m = folium.Map(location=loc,
       center=center, zoom_start=13)

title_html = '''
     <h3 align="center" style="font-size:20px"><b>Titly title</b></h3>
     ''' 
m.get_root().html.add_child(folium.Element(title_html))
display(m)

enter image description here

But this creates a scrollbar, which makes navigating a bit uncomfortable. Before adding the title I had no problems, as you can see:

enter image description here

So, is there any way to add a title without adding a scrollbar?

Thanks!

Juan C
  • 5,846
  • 2
  • 17
  • 51

1 Answers1

2

It's related to the html's style properties which is mostly stated between the <head></head> tags. So yo can convert the variable title_html as below :

title_html = '''
     <head><style> html { overflow-y: hidden; } </style></head>
     <h3 align="center" style="font-size:20px"><b>Titly title</b></h3>
     ''' 
Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
  • 1
    Nice! it worked like a charm, thanks. I guessed I could do something with the html, but my knowledge is quite basic. – Juan C Apr 02 '20 at 18:07
  • 1
    Note that if you use `format()` you may have to [double the braces](https://stackoverflow.com/a/9623246/812102) in order to pass the `KeyError: ' overflow-y'` error. – Skippy le Grand Gourou Jan 07 '21 at 21:32