This is the documentation of version 0.57.0. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Type Alias KnobDescriptor<T>

    A single, machine-readable description of one display knob.

    The point of describing knobs as data is that a caller — increasingly a coding agent rather than a person reading docs — can ask what a module actually exposes instead of guessing layer ids from training data. Three things follow from having it:

    • ground before generating — write against what the module exposes, not what you remember;
    • validate — ranges and allowed values arrive as data, so a bad value is caught before it is rendered;
    • report and diff — the paired settings object is plain and serializable, so a display change is reviewable in a pull request.

    A visual editor cannot do any of those: it cannot be read, diffed, or put in a pull request.

    Modules narrow this shape with their own descriptor type — e.g. StylingKnobDescriptor requires available and appliesTo, while a module whose knobs are always applicable omits them.

    type KnobDescriptor<T = unknown> = {
        appliesTo?: string;
        available?: boolean;
        current: T;
        default: T;
        description: string;
        id: string;
        kind: KnobKind;
        options?: readonly string[];
        overridden: boolean;
        range?: KnobRange;
    }

    Type Parameters

    • T = unknown
    Index
    appliesTo?: string

    Which styles or contexts the knob works in. A string rather than a fixed union so each module can choose its own vocabulary — styling uses 'any-style' | 'tomtom-styles'.

    available?: boolean

    Whether the knob has anything to work on in the loaded style. Omitted by modules whose knobs are always applicable; set to false by modules where a knob can be present in the catalogue but do nothing on the current style.

    current: T

    The value in force now.

    default: T

    The value in force when nothing has been configured.

    description: string

    One-line description of what turning this knob does.

    id: string

    Stable, dotted identifier, e.g. labels.sizeFactor. Treat these as public API: they are what a caller stores, diffs and passes back.

    kind: KnobKind

    What kind of value the knob takes.

    options?: readonly string[]

    The allowed values, for enum knobs; the names accepted besides CSS colours, for colors knobs.

    overridden: boolean

    Whether KnobDescriptor.current came from configuration rather than the default.

    range?: KnobRange

    Inclusive bounds, for factor and number knobs.