Change a layer's color with buttons
This source code of this example is adapted from the MapLibre GL JS example - Change a layer's color with buttons.
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=[12.338, 45.4385], zoom=17, style="streets")
m
m = leafmap.Map(center=[12.338, 45.4385], zoom=17, style="streets")
m
Failed to retrieve the MapTiler style. Defaulting to OpenFreeMap 'liberty' style.
In [5]:
Copied!
m.style_layer_interact(id="water")
m.style_layer_interact(id="water")
The provided color (rgb(158,189,255)) is invalid. Using the default black color. '#rgb(158,189,255)' is not in web format. Need 3 or 6 hex digit.