In [1]:
Copied!
# %pip install "leafmap[maplibre]"
# %pip install "leafmap[maplibre]"
In [2]:
Copied!
import leafmap.maplibregl as leafmap
import leafmap.maplibregl as leafmap
In [3]:
Copied!
# import os
# os.environ["MAPTILER_KEY"] = "YOUR_API_KEY"
# import os
# os.environ["MAPTILER_KEY"] = "YOUR_API_KEY"
By default, if the style parameter is not provided, the default dark-matter style from CartoDB will be used. Other styles can be found here, including positron, voyager, dark-matter-nolabels, positron-nolabels, and voyager-nolabels.
In [4]:
Copied!
m = leafmap.Map(style="dark-matter")
m
m = leafmap.Map(style="dark-matter")
m
If you have a MapTiler API key, you can use any basemap available in the MapTiler Basemap style gallery by specifying the style parameter. For example, style='satellite' will use the satellite basemap from MapTiler.

In [5]:
Copied!
m = leafmap.Map(center=[-100, 40], zoom=3, style="streets")
m
m = leafmap.Map(center=[-100, 40], zoom=3, style="streets")
m
You can also use any raster basemaps from xyzservices. For example, style='OpenTopoMap' will use the OpenTopoMap basemap.
In [6]:
Copied!
m = leafmap.Map(center=[-100, 40], zoom=3)
m.add_basemap("OpenTopoMap")
m
m = leafmap.Map(center=[-100, 40], zoom=3)
m.add_basemap("OpenTopoMap")
m
If you don't know the name of the basemap, you can use the add_basemap() function to get a list of basemaps and select the one you like.
In [7]:
Copied!
m.add_basemap()
m.add_basemap()
