Atlaslog
Atlaslog / Field Notes / MapLibre styles & layers
Field note · MapLibre styles & layers

setTerrain is accepted but the ground stays flat

Quick answer

map.getTerrain() returns the configuration and no error fires, yet tilting the camera shows no relief because the DEM source is mistyped or mis-encoded. A wrong encoding yields either near-zero heights or huge spikes.

Last verified 2026-11-03 · Multiple versions · Cite this page
Applies to: MapLibre GL JS
Symptom
Checklist
  1. Print map.getSource('terrain').type and map.getTerrain().
  2. Check the declared encoding against the DEM producer, terrarium versus mapbox.
  3. Download one DEM tile and check whether it is 256x256 or 512x512.
  4. Check maxzoom against the current zoom and whether the view is tilted at all.
Fix

Declare type: 'raster-dem' with encoding 'terrarium', tileSize matching the tiles, minzoom 0 and maxzoom 12, then setTerrain with exaggeration 1.5 and setPitch(55) so relief becomes visible.

Code
Error: Source "terrain" cannot be used as terrain because it is not a raster-dem source.
var src = map.getSource('terrain');
console.log('源类型', src.type);
console.log('地形配置', map.getTerrain());
map.on('error', function (e) { console.error(e.error && e.error.message); });
Watch out
All 120 field notesChinese originalRunnable examples
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Cite this page

Atlaslog (2026). setTerrain is accepted but the ground stays flat. https://www.jingweizhi.com/en/cookbook/maplibre-terrain-not-work.html (accessed 2026-11-03).