The lifecycle events of this module. The module owns no map features, so it has no user
interaction events. config-change fires with the full settings after every knob change.
The advanced tier, with raw MapLibre paint, layout and filter edits over a query of the style's own layers, re-applied across style switches. These edits are coupled to the style version, as LayerSelection explains, so prefer a knob or setMapColors wherever one covers the intent.
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);
Exports the style as currently rendered, with every knob applied, as a MapLibre style specification to save, diff or serve yourself.
It includes whatever the SDK's data modules (places, routes) have on the map. Its tile URLs
carry the API key the map was created with, so strip or rotate the key before publishing.
Labels set in a customTypeface come out in the style's own Noto faces, since only the SDK can
draw font files beside the glyph service.
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
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();
Recolours the whole base map with up to ten semantic colours in one call, and sets accent, the
default colour of routes, geometries and places (TomTomMap.mapColors).
The ten are the style themes' Foundations palette, each listed with what it reaches under
MapColorName. Partial objects are fine. The colours you leave out stay as they are,
except on the mono styles, which derive the other nine from land as their theme does. There,
the theme's own formulas re-derive them from the given land.
The colours to set, as CSS colour strings.
Each colour re-derives every shade the style built from it, such as a trunk variant, an outline
or a tunnel, at the style's own HSL offset, so those relationships survive the recolour. The
colours are also the colors.* knobs, so getKnob, resetKnob and settings persistence apply.
The offsets come from the loaded style, which makes a palette a recolour and not an inversion.
Dark land over streetLight pushes the derived shades to the ends of their range, so switch to
streetDark first.
styling.setMapColors({ land: '#f3f5f7', water: '#accbe2', roadMajor: '#a1b8ce', label: '#364659' });
resetKnob(styling, stylingFoundationsKnobCatalogue, 'colors.roadMajor'); // one colour back to the style
styling.setMapColors(deriveMapColors(['#0b2a3a', '#0fa8c8', '#f6efe3'])); // map-theme plugin assigns the roles
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 styling foundations module of the given map, creating it on first use.
Optionalsettings: StylingFoundationsModuleConfig
Knob values to apply right away, e.g. restored from storage.
A promise that resolves once the map style is loaded and the settings are applied.
The foundations of the whole map's look, with sizes across every part of the style, the ten map colours and the accent, the projection, the sky and the light on the 3D buildings.
It is the tier between showing or hiding a part of the map and hand-editing MapLibre layers. Every adjustable thing is a knob with a stable id, a kind, a range and a default read from the loaded style. The ids form the StylingFoundationsKnobId union, and stylingFoundationsKnobCatalogue lists each one's kind, range and description as data, with no map needed to read it. Each id is its path into StylingFoundationsModuleConfig. setKnob, setKnobs, getKnob and resetKnob set, read and unset knobs by id, as on every module.
Remarks
The catalogue's
appliesTosays which styles a knob works on.any-styleknobs (sizes, widths) scale whatever the style already does, so they survive style-version bumps. A zoom ramp has each stop's output scaled, and any other expressionEbecomes["*", 1.3, E].tomtom-stylesknobs (the map colours) reach their layers through the TomTom styles this SDK version is verified against. On a style layer they do not recognise, setting one warns once and does nothing.After every
setStylethat carries state over, the settings are re-applied on top of whatever the other modules restored. A clean switch (resetState: true) drops them.Each part of the map's look belongs to its own module. POIsModule sizes and colours the POIs, TrafficFlowModule and TrafficIncidentsModule the traffic lines, TerrainModule the hillshade, and BaseMapModule shows and hides the layer groups and the road markings within them. The sizes here compose with theirs, so
labels.sizeFactorand the POIs'sizeFactormultiply on the POI labels.Example
See
Map Styling Guide