Skip to content

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.

PropertyTypeDescription
type"raster"Layer type (required).
sourceSource | stringThe raster-tile or raster-dem source (required).
MaterialConfig keyDescription
RasterMaterialrasterImagery appearance (color, opacity, …).
HillshadeMaterialhillshadeShaded relief from a raster-dem source.
ElevationHeatmapMaterialelevationHeatmapColor-coded elevation from a raster-dem source.
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 } });

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 },
});
view.addLayer({
type: "raster",
source: dem,
elevationHeatmap: {
maxHeight: 3000,
minHeight: 0,
logarithmic: true,
logBoundary: 1000,
},
});