Terrain
The Terrain component adds 3D terrain elevation to the map using a raster DEM (Digital Elevation Model) source.Import
Basic Usage
Props
sourceID
Name of a source of
raster_dem type to be used for terrain elevation. The source must be added to the map before the Terrain component.exaggeration
Exaggerates the elevation of the terrain by multiplying the data from the DEM with this value.
style
Customizable style attributes for the terrain.
Style Properties
exaggeration
Exaggerates the elevation of the terrain by multiplying the data from the DEM with this value.
- Minimum: 0
- Maximum: 1000
- Supports expressions: Yes (with
zoomparameter) - Requires:
sourceIDto be set
exaggerationTransition
style.exaggerationTransition
{ duration: number, delay?: number }
default:"{ duration: 300, delay: 0 }"
The transition affecting any changes to the exaggeration property.
- Units: milliseconds
Examples
- Basic Terrain
- Exaggerated Terrain
- Dynamic Exaggeration
- Zoom-based Exaggeration
Using Custom DEM Sources
You can use custom DEM sources instead of Mapbox’s terrain:Performance Considerations
- Terrain rendering can be computationally expensive, especially on lower-end devices
- Higher exaggeration values may impact performance
- Consider reducing the
pitchcamera angle when not focusing on terrain - Use appropriate zoom levels - terrain is most effective at zoom levels 10-16
Related Components
- RasterDemSource - Provides elevation data for terrain
- Camera - Control the viewing angle (pitch is important for terrain)
- MapView - The map container
- HillshadeLayer - Alternative way to visualize elevation