Skip to content

01 leafmap intro

image image image

Introducing the leafmap Python package for interactive mapping

Uncomment the following line to install leafmap if needed.

1
# !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
1
import leafmap

Create an interactive map.

1
2
m = leafmap.Map()
m

Specify the default map center and zoom level.

1
2
m = leafmap.Map(center=[50, 19], zoom=4)  # center=[lat, lon]
m

Set the visibility of map controls.

1
2
3
4
5
6
7
m = leafmap.Map(
    draw_control=False,
    measure_control=False,
    fullscreen_control=False,
    attribution_control=True,
)
m

Change the map width and height.

1
2
m = leafmap.Map(height="450px", width="800px")
m

Use the ipyleaflet plotting backend.

1
import leafmap.leafmap as leafmap
1
2
m = leafmap.Map()
m

Use the folium plotting backend.

1
import leafmap.foliumap as leafmap
1
2
m = leafmap.Map()
m