TomTom Maps for JavaScript
    Preparing search index...

    Function setKnobs

    • Sets several knobs by their catalogue ids in one change, after checking every value with validateKnobValue, and keeps every other setting.

      Type Parameters

      • CONFIG
      • ID extends string

      Parameters

      • module: KnobTarget<CONFIG>

        A map module, or a plugin with knobs, such as MapEffects.

      • catalogue: readonly KnobEntry<ID>[]

        Its knob catalogue, e.g. routingKnobCatalogue for a RoutingModule.

      • values: KnobValues<CONFIG, ID>

        The values by knob id. An empty record changes nothing.

      Returns void

      Nothing changes when any id or value is invalid. Otherwise the module applies its configuration once, so it redraws and fires config-change once, however many knobs you set.

      Use the knob functions for settings held as data, and the module's config methods for settings your code writes:

      • setKnob / setKnobs take ids and values from a control, storage, a URL or a language model. They check each value, reach a nested setting and keep the ones beside it, and cover the plain-valued settings the catalogue lists.
      • applyConfig / updateConfig take a typed configuration, including what no knob covers (layer specs, callbacks, MapLibre expressions). They check nothing at run time, and updateConfig replaces a nested object you pass.

      RangeError for a value its knob does not take; Error for an id the catalogue lacks.

      setKnobs(routing, routingKnobCatalogue, { widthPreset: 'l', 'waypoints.label.color': '#e63312' });
      setKnobs(styling, stylingFoundationsKnobCatalogue, JSON.parse(localStorage.getItem('styling') ?? '{}'));