01 leafmap intro
Introducing the leafmap Python package for interactive mapping
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# !pip install leafmap
# !pip install leafmap
leafmap
has four plotting backends: folium, ipyleaflet, here-map, and kepler.gl. Note that the backends do not offer equal functionality. Some interactive functionality in ipyleaflet
might not be available in other plotting backends. To use a specific plotting backend, use one of the following:
import leafmap.leafmap as leafmap
import leafmap.foliumap as leafmap
import leafmap.heremap as leafmap
import leafmap.kepler as leafmap
In [2]:
Copied!
import leafmap
import leafmap
Create an interactive map.
In [3]:
Copied!
m = leafmap.Map()
m
m = leafmap.Map()
m
Out[3]:
Specify the default map center and zoom level.
In [4]:
Copied!
m = leafmap.Map(center=[50, 19], zoom=4) # center=[lat, lon]
m
m = leafmap.Map(center=[50, 19], zoom=4) # center=[lat, lon]
m
Out[4]:
Set the visibility of map controls.
In [5]:
Copied!
m = leafmap.Map(
draw_control=False,
measure_control=False,
fullscreen_control=False,
attribution_control=True,
)
m
m = leafmap.Map(
draw_control=False,
measure_control=False,
fullscreen_control=False,
attribution_control=True,
)
m
Out[5]:
Change the map width and height.
In [6]:
Copied!
m = leafmap.Map(height="450px", width="800px")
m
m = leafmap.Map(height="450px", width="800px")
m
Out[6]:
Use the ipyleaflet
plotting backend.
In [7]:
Copied!
import leafmap.leafmap as leafmap
import leafmap.leafmap as leafmap
In [8]:
Copied!
m = leafmap.Map()
m
m = leafmap.Map()
m
Use the folium
plotting backend.
In [9]:
Copied!
import leafmap.foliumap as leafmap
import leafmap.foliumap as leafmap
In [10]:
Copied!
m = leafmap.Map()
m
m = leafmap.Map()
m
Out[10]: