Change the case of labels
This source code of this example is adapted from the MapLibre GL JS example - Change the case of labels.
Uncomment the following line to install leafmap if needed.
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"
In [4]:
Copied!
m = leafmap.Map(center=[-116.231, 43.604], zoom=11, style="streets")
geojson = {
"type": "geojson",
"data": "https://maplibre.org/maplibre-gl-js/docs/assets/boise.geojson",
}
m.add_source("off-leash-areas", geojson)
layer = {
"id": "off-leash-areas",
"type": "symbol",
"source": "off-leash-areas",
"layout": {
"icon-image": "dog-park-11",
"text-field": [
"format",
["upcase", ["get", "FacilityName"]],
{"font-scale": 0.8},
"\n",
{},
["downcase", ["get", "Comments"]],
{"font-scale": 0.6},
],
"text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"],
"text-offset": [0, 0.6],
"text-anchor": "top",
},
}
m.add_layer(layer)
m
m = leafmap.Map(center=[-116.231, 43.604], zoom=11, style="streets")
geojson = {
"type": "geojson",
"data": "https://maplibre.org/maplibre-gl-js/docs/assets/boise.geojson",
}
m.add_source("off-leash-areas", geojson)
layer = {
"id": "off-leash-areas",
"type": "symbol",
"source": "off-leash-areas",
"layout": {
"icon-image": "dog-park-11",
"text-field": [
"format",
["upcase", ["get", "FacilityName"]],
{"font-scale": 0.8},
"\n",
{},
["downcase", ["get", "Comments"]],
{"font-scale": 0.6},
],
"text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"],
"text-offset": [0, 0.6],
"text-anchor": "top",
},
}
m.add_layer(layer)
m
Failed to retrieve the MapTiler style. Defaulting to OpenFreeMap 'liberty' style.