Display and style rich text labels
This source code of this example is adapted from the MapLibre GL JS example - Display and style rich text 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=[9.49, 49.01], zoom=4, style="basic")
m.set_layout_property(
"label_country",
"text-field",
[
"format",
["get", "name_en"],
{"font-scale": 1.2},
"\n",
{},
["get", "name"],
{
"font-scale": 0.8,
"text-font": [
"literal",
["DIN Offc Pro Italic", "Arial Unicode MS Regular"],
],
},
],
)
m
m = leafmap.Map(center=[9.49, 49.01], zoom=4, style="basic")
m.set_layout_property(
"label_country",
"text-field",
[
"format",
["get", "name_en"],
{"font-scale": 1.2},
"\n",
{},
["get", "name"],
{
"font-scale": 0.8,
"text-font": [
"literal",
["DIN Offc Pro Italic", "Arial Unicode MS Regular"],
],
},
],
)
m
Failed to retrieve the MapTiler style. Defaulting to 'dark-matter' style.