60 add widget
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# !pip install -U leafmap
# !pip install -U leafmap
In [2]:
Copied!
import leafmap
import leafmap
Add text.
In [3]:
Copied!
m = leafmap.Map()
text = 'Hello World'
m.add_text(text, position='bottomright')
m
m = leafmap.Map()
text = 'Hello World'
m.add_text(text, position='bottomright')
m
Out[3]:
Customize text style.
In [4]:
Copied!
m = leafmap.Map()
text = 'Hello World'
params = {
'fontsize': 30,
'fontcolor': 'blue',
'bold': True,
'padding': '10px',
'background': True,
'bg_color': 'white',
'border_radius': '5px',
'position': 'bottomright',
}
m.add_text(text, **params)
m
m = leafmap.Map()
text = 'Hello World'
params = {
'fontsize': 30,
'fontcolor': 'blue',
'bold': True,
'padding': '10px',
'background': True,
'bg_color': 'white',
'border_radius': '5px',
'position': 'bottomright',
}
m.add_text(text, **params)
m
Out[4]:
In [5]:
Copied!
m = leafmap.Map(measure_control=False, scale_control=False)
left = 'ESA WorldCover 2021 S2 FCC'
right = 'ESA WorldCover 2021 S2 TCC'
m.split_map(left_layer=left, right_layer=right)
m.add_text(left, position='bottomleft')
m.add_text(right, position='bottomright')
m
m = leafmap.Map(measure_control=False, scale_control=False)
left = 'ESA WorldCover 2021 S2 FCC'
right = 'ESA WorldCover 2021 S2 TCC'
m.split_map(left_layer=left, right_layer=right)
m.add_text(left, position='bottomleft')
m.add_text(right, position='bottomright')
m
Out[5]:
Add image.
In [6]:
Copied!
m = leafmap.Map()
image = 'https://i.imgur.com/LmTETPX.png'
m.add_image(image, position='bottomright')
m
m = leafmap.Map()
image = 'https://i.imgur.com/LmTETPX.png'
m.add_image(image, position='bottomright')
m
Out[6]:
Add HTML.
In [7]:
Copied!
m = leafmap.Map()
html = """
<h2>Jupyter Logo</h2>
<img src="https://i.imgur.com/LmTETPX.png">
"""
m.add_html(html, position='bottomright')
m
m = leafmap.Map()
html = """
"""
m.add_html(html, position='bottomright')
m
Jupyter Logo

Out[7]:
Add widget.
In [8]:
Copied!
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.pyplot as plt
In [9]:
Copied!
# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
fig, ax = plt.subplots(figsize=(4, 3))
ax.plot(t, s)
ax.set(
xlabel='time (s)', ylabel='voltage (mV)', title='About as simple as it gets, folks'
)
ax.grid()
# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
fig, ax = plt.subplots(figsize=(4, 3))
ax.plot(t, s)
ax.set(
xlabel='time (s)', ylabel='voltage (mV)', title='About as simple as it gets, folks'
)
ax.grid()
In [10]:
Copied!
m = leafmap.Map()
m.add_widget(fig, position='bottomright')
m
m = leafmap.Map()
m.add_widget(fig, position='bottomright')
m
Out[10]:
Last update:
2023-04-05
Created: 2021-03-10
Created: 2021-03-10