Add a raster tile source
This source code of this example is adapted from the MapLibre GL JS example - Add a raster tile source.
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# %pip install "leafmap[maplibre]"
# %pip install "leafmap[maplibre]"
In [2]:
Copied!
import os
import leafmap.maplibregl as leafmap
import os
import leafmap.maplibregl as leafmap
In [3]:
Copied!
style = {
"version": 8,
"sources": {
"raster-tiles": {
"type": "raster",
"tiles": [
"https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg"
],
"tileSize": 256,
"attribution": 'Map tiles by <a target="_blank" href="https://stamen.com">Stamen Design</a>; Hosting by <a href="https://stadiamaps.com/" target="_blank">Stadia Maps</a>. Data © <a href="https://www.openstreetmap.org/about" target="_blank">OpenStreetMap</a> contributors',
}
},
"layers": [
{
"id": "simple-tiles",
"type": "raster",
"source": "raster-tiles",
"minzoom": 0,
"maxzoom": 22,
}
],
}
style = {
"version": 8,
"sources": {
"raster-tiles": {
"type": "raster",
"tiles": [
"https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg"
],
"tileSize": 256,
"attribution": 'Map tiles by Stamen Design; Hosting by Stadia Maps. Data © OpenStreetMap contributors',
}
},
"layers": [
{
"id": "simple-tiles",
"type": "raster",
"source": "raster-tiles",
"minzoom": 0,
"maxzoom": 22,
}
],
}
In [4]:
Copied!
m = leafmap.Map(center=[-74.5, 40], zoom=2, style=style)
m
m = leafmap.Map(center=[-74.5, 40], zoom=2, style=style)
m