Trying to remove bottom padding in map._repr_html_() in my Python web app

1.2k views Asked by At

I made this folium map converted it to HTML and named it html_map then added it to my a template in my Python app using {{ location_map | safe}} and trying to get rid of the bottom padding how can I do this.

map = folium.Map([0.376568,32.663343],width="100%",height="45%", zoom_start="13")
l = folium.FeatureGroup(name="Location")
folium.Marker(location=[0.376568,32.663343],popup="This is our office location 0.376568,32.663343, feel free to visit Namugongo,Mbalwa",icon=folium.Icon(color='green', icon='briefcase', prefix='fa')).add_to(l)
map.add_child(l)
map.add_child(folium.LayerControl(position='topleft',collapsed=True,))

html_map = map._repr_html_()

This is some of the HTML in html_map;

<div style="width:100%;"><div style="position:relative;width:100%;height:0;padding-bottom:60%;"><span style="color:#565656">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe src="about:blank" style="position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;" data-html=PCFET0NUWVBFIGh0bWw+CjxoZWFkPiAgICAKICAgIDxtZXRhIGh0dHAtZX 
1

There are 1 answers

1
Henri Piot On

I just find a way to do this. You need to modify the HTML constructed and push by _repr_html_().

You just avec to construct a new long-string as string are immutable in Python, thus, for the padding you can write:

 m=m._repr_html_() #updated
 m = m[:90] + '70' + m[92:]

This will replace the by default 60% padding to you desired value!