Raster Layer
A raster layer renders a raster-tile source as imagery, or a raster-dem source as hillshade or an elevation heatmap. When a terrain layer is present, the imagery is draped onto the 3D surface. Otherwise it renders on the flat globe.
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
type | "raster" | Layer type (required). |
source | Source | string | The raster-tile or raster-dem source (required). |
Render options
Section titled “Render options”| Material | Config key | Description |
|---|---|---|
| RasterMaterial | raster | Visibility and opacity of the layer, and the imagery’s color. |
| HillshadeMaterial | hillshade | Shaded relief from a raster-dem source. |
| ElevationHeatmapMaterial | elevationHeatmap | Color-coded elevation from a raster-dem source. |
raster applies to whatever the layer draws. show hides the hillshade or the elevation heatmap too, and opacity sets the opacity of the imagery and the elevation heatmap and how strongly the hillshade shades the terrain. color tints only the imagery. A layer that sets both hillshade and elevationHeatmap draws only the hillshade.
Examples
Section titled “Examples”Imagery
Section titled “Imagery”import ThreeView from "@navaramap/three";
const view = new ThreeView(/* options */);await view.init();
const imagery = view.addSource({ type: "raster-tile", url: "https://tile.openstreetmap.org/{z}/{x}/{y}.png", maxZoom: 19,});
view.addLayer({ type: "raster", source: imagery, raster: { opacity: 1 } });Hillshade
Section titled “Hillshade”Reference a raster-dem source. The decoder lives on the source.
import ThreeView, { TERRARIUM_ELEVATION_DECODER } from "@navaramap/three";
const dem = view.addSource({ type: "raster-dem", url: "https://example.com/terrarium/{z}/{x}/{y}.png", elevationDecoder: TERRARIUM_ELEVATION_DECODER(), maxZoom: 17, minZoom: 5,});
view.addLayer({ type: "raster", source: dem, hillshade: { exaggeration: 0.5 },});Elevation heatmap
Section titled “Elevation heatmap”view.addLayer({ type: "raster", source: dem, elevationHeatmap: { maxHeight: 3000, minHeight: 0, logarithmic: true, logBoundary: 1000, },});Draped layer limit
Section titled “Draped layer limit”Only a limited number of layers can be draped on the terrain at once, and the number depends on the device. A raster layer hidden with raster: { show: false } does not count toward it, so alternative basemaps can stay added and be switched with show.
When more layers are shown than fit, the topmost ones are not drawn and the console logs Too many layers draped on the terrain: …. See issue #1039 for the details of the limit and the planned improvements.
Related Resources
Section titled “Related Resources”- Raster Tile Source / Raster DEM Source
- RasterMaterial / HillshadeMaterial / ElevationHeatmapMaterial
- Terrain Layer: drape imagery onto 3D terrain