TomTom Maps for JavaScript
    Preparing search index...

    Function setKnob

    • Sets one knob by its catalogue id, after checking the value with validateKnobValue, and keeps every other setting.

      Type Parameters

      • CONFIG
      • ID extends string
      • KNOB 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. trafficFlowKnobCatalogue for a TrafficFlowModule.

      • id: KNOB

        The knob's id.

      • value: KnobInput<CONFIG, KNOB>

      Returns void

      Nothing changes when the value is invalid. A knob's id is its dotted path into the module's configuration, so the change also shows in getConfig and fires a config-change event. To set several knobs in one change, use setKnobs.

      Use it for a value held as data, from a control, storage or a language model, since it checks the value and keeps the settings beside it. For typed settings your code writes, including the ones no knob covers, use the module's applyConfig or updateConfig, which check nothing at run time.

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

      setKnob(trafficFlow, trafficFlowKnobCatalogue, 'filters.roadCategories.show', 'only');
      setKnob(styling, stylingFoundationsKnobCatalogue, 'labels.sizeFactor', 1.2);