Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
python-visualization
GitHub Repository: python-visualization/folium
Path: blob/main/tests/plugins/test_float_image.py
2531 views
1
"""
2
Test FloatImage
3
---------------
4
"""
5
6
import folium
7
from folium import plugins
8
from folium.template import Template
9
from folium.utilities import normalize
10
11
12
def test_float_image():
13
m = folium.Map([45.0, 3.0], zoom_start=4)
14
url = "https://raw.githubusercontent.com/SECOORA/static_assets/master/maps/img/rose.png"
15
szt = plugins.FloatImage(url, bottom=60, left=70, width="20%")
16
m.add_child(szt)
17
m._repr_html_()
18
19
out = normalize(m._parent.render())
20
21
# Verify that the div has been created.
22
tmpl = Template("""
23
<img id="{{this.get_name()}}" alt="float_image"
24
src="https://raw.githubusercontent.com/SECOORA/static_assets/master/maps/img/rose.png"
25
style="z-index: 999999">
26
</img>
27
""")
28
assert normalize(tmpl.render(this=szt)) in out
29
30
# Verify that the style has been created.
31
tmpl = Template("""
32
<style>
33
#{{this.get_name()}} {
34
position: absolute;
35
bottom: 60%;
36
left: 70%;
37
width: 20%;
38
}
39
</style>
40
""")
41
assert normalize(tmpl.render(this=szt)) in out
42
43
bounds = m.get_bounds()
44
assert bounds == [[None, None], [None, None]], bounds
45
46