Change case of labels

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.
| # %pip install "leafmap[maplibre]"
|
| import leafmap.maplibregl as leafmap
|
To run this notebook, you will need an API key from MapTiler. Once you have the API key, you can uncomment the following code block and replace YOUR_API_KEY with your actual API key. Then, run the code block code to set the API key as an environment variable.
| # import os
# os.environ["MAPTILER_KEY"] = "YOUR_API_KEY"
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 | 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
|
