Change building color based on zoom level
Replicates the MapLibre example Change building color based on zoom level.
The complete document
Section titled “The complete document”# yaml-language-server: $schema=https://docs.maplibre-yaml.org/schema/latest/map.schema.json# Gallery twin of https://maplibre.org/maplibre-gl-js/docs/examples/change-building-color-based-on-zoom-level/# Zoom from 15 to 17: the interpolate expression eases the fill from sand# to terracotta. The layer draws from the basemap's own vector source.type: mapid: change-building-color-based-on-zoom-levelconfig: center: [-90.0715, 29.9511] zoom: 15 mapStyle: "https://tiles.openfreemap.org/styles/liberty"layers: - id: buildings-by-zoom type: fill source: openmaptiles source-layer: building minzoom: 14 paint: fill-color: - interpolate - ["exponential", 0.5] - ["zoom"] - 15 - "#e8d8c3" - 17 - "#c47a5a" fill-opacity: 0.85What to notice
Section titled “What to notice”- An
interpolateon["zoom"]with an exponential base, applied to the basemap’s ownbuildingsource-layer — the same basemap-extension trick as the 3D-buildings page.