The lifecycle events of this module. The hillshade is a raster layer with no features to
interact with, so it has no user interaction events. config-change fires after every change.
The MapLibre source and layer IDs of all sources this module creates and manages.
A record mapping each source name to its MapLibre source ID and an array of the IDs of that source's layers.
Applies a configuration to this module.
The module updates its behaviour and appearance to match. It stores the configuration and reapplies it automatically when the map style changes.
The configuration to apply. Pass undefined to reset it to the default values.
The given configuration replaces the current one rather than being merged into it. To change one part of it, use updateConfig.
Use it for settings your code writes. It takes every setting, typed, including the ones no knob covers (layer specs, callbacks, MapLibre expressions), and checks no value at run time. For settings held as data, from a control, storage or a language model, use setKnobs.
// Apply a new configuration
myModule.applyConfig({ visible: true, color: '#E63312' });
// Reset to default configuration
myModule.applyConfig(undefined);
Returns a shallow copy of the current module configuration, or undefined if none is applied.
A shallow copy of the current configuration, or undefined. It is a copy so that you
can't modify the internal state by accident.
Only the top-level properties are copied. Nested objects and arrays still reference the original configuration. This is enough for most use cases, but keep it in mind with complex configurations.
// Apply a configuration
myModule.applyConfig({ visible: true, color: '#E63312' });
// Later, retrieve the current configuration
const currentConfig = myModule.getConfig();
console.log(currentConfig); // { visible: true, color: '#E63312' }
// When no config is applied
myModule.resetConfig();
console.log(myModule.getConfig()); // undefined
Whether the map surface is set to be raised in 3D.
The elevation.visible setting or, while nothing has set it, whether the map's own terrain raises it.
Whether the hillshade shading is set to be shown.
The hillshade.visible setting, or false while nothing has set it, since the hillshade is hidden until shown.
Resets this module's configuration to its default values.
It clears any applied configuration and restores the module to its initial state, the same
as calling applyConfig(undefined).
The module then behaves as if no configuration was ever applied. Any custom settings, styling or behaviour changes are replaced with default values.
// Apply some configuration
myModule.applyConfig({ visible: true, color: '#E63312' });
// Later, reset to defaults
myModule.resetConfig();
Raises the map surface in 3D, or flattens it, keeping the configured exaggeration.
Shows or hides the hillshade shading.
Changes part of the configuration and keeps the rest.
The given properties are laid over the current configuration one level deep, so a nested
object you pass replaces the one that was there. The result is applied with
applyConfig. This works the same on every module, whatever its applyConfig does with
a whole configuration.
The properties to change.
Use it for settings your code writes, as applyConfig: typed, and not checked at run time. To change nested values and keep the ones beside them, or to set values held as data, use setKnobs, which reaches each by its path and checks it.
routing.applyConfig({ displayUnits: { distance: { type: 'imperial_us' } }, color: '#0a3653' });
routing.updateConfig({ color: '#c2185b' }); // displayUnits stays imperial
applyConfig to apply a whole configuration
StaticgetRetrieves the terrain module of the given map, adding the elevation style part first when the style lacks it.
Optionalconfig: TerrainModuleConfig
Without it on the first call, the hillshade is hidden and the surface stays as the map draws it. A later call without it leaves the instance's config as it is.
The terrain relief module, with hillshade shading and the 3D surface, both drawn from the elevation data of the map style.
Remarks
This module owns the hillshade (whether it is shown, and its shading method, light direction, strength, zoom range and colours) and whether and how high the surface is raised. See Who owns what. terrainKnobCatalogue lists every setting of its configuration.
get()adds the elevation style part when the style lacks it, and the module restores both after every style change. The 3D surface reads its own copy of the elevation source, TERRAIN_SOURCE_ID.Example
See
Terrain Guide