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
RasterMaterialrasterVisibility and opacity of the layer, and the imagery’s color.
HillshadeMaterialhillshadeShaded relief from a raster-dem source.
ElevationHeatmapMaterialelevationHeatmapColor-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.

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,
},
});

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.