In [1]:
import os
import folium
print(folium.__version__)
In [2]:
from branca.element import Figure
lon, lat = -122.1889, 46.1991
location = [lat, lon]
zoom_start = 13
tiles = 'OpenStreetMap'
In [3]:
width, height = 480, 350
fig = Figure(width=width, height=height)
m = folium.Map(
location=location,
tiles=tiles,
width=width,
height=height,
zoom_start=zoom_start
)
fig.add_child(m)
fig.save(os.path.join('results', 'WidthHeight_0.html'))
fig
Out[3]:
In [4]:
width, height = '100%', 350
fig = Figure(width=width, height=height)
m = folium.Map(
location=location,
tiles=tiles,
width=width,
height=height,
zoom_start=zoom_start
)
fig.add_child(m)
fig.save(os.path.join('results', 'WidthHeight_1.html'))
fig
Out[4]:
In [5]:
width, height = 480, '100%'
fig = Figure(width=width, height=height)
m = folium.Map(
location=location,
tiles=tiles,
width=width,
height=height,
zoom_start=zoom_start
)
fig.add_child(m)
fig.save(os.path.join('results', 'WidthHeight_2.html'))
fig
Out[5]:
In [6]:
width, height = '50%', '100%'
fig = Figure(width=width, height=height)
m = folium.Map(
location=location,
tiles=tiles,
width=width,
height=height,
zoom_start=zoom_start
)
fig.add_child(m)
fig.save(os.path.join('results', 'WidthHeight_3.html'))
fig
Out[6]:
In [7]:
width, height = '150%', '100%'
try:
folium.Map(location=location, tiles=tiles,
width=width, height=height, zoom_start=zoom_start)
except ValueError as e:
print(e)
In [8]:
width, height = '50%', '80p'
try:
folium.Map(location=location, tiles=tiles,
width=width, height=height, zoom_start=zoom_start)
except ValueError as e:
print(e)
In [9]:
width, height = width, height = 480, -350
try:
folium.Map(location=location, tiles=tiles,
width=width, height=height, zoom_start=zoom_start)
except ValueError as e:
print(e)
In [10]:
width, height = 480, 350
fig = Figure(width=width, height=height)
m = folium.Map(
location=location,
tiles=tiles,
width='100%',
height='100%',
zoom_start=zoom_start
)
fig.add_child(m)
fig.save(os.path.join('results', 'WidthHeight_4.html'))
fig
Out[10]: