Skip to content

Add a hillshade layer

Replicates the MapLibre example Add a hillshade layer: Mount Hood in relief.

add-a-hillshade-layer.yaml
# 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/add-a-hillshade-layer/
type: map
id: add-a-hillshade-layer
config:
center: [-121.696, 45.374]
zoom: 11
mapStyle: "https://demotiles.maplibre.org/style.json"
layers:
- id: hillshade
type: hillshade
source:
type: raster-dem
tiles:
- "https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"
encoding: terrarium
tileSize: 256
maxzoom: 14
attribution: "Terrain tiles: Mapzen/AWS Open Data"
paint:
hillshade-shadow-color: "#473B24"
hillshade-exaggeration: 0.6
  • A raster-dem source (encoding: terrarium for AWS elevation tiles) plus a hillshade layer — no JS, no plugins.
  • Add map-level terrain: over the same kind of source and the hillshade becomes 3D relief — see 3D terrain.