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

    Type Alias GeometryLabelConfig

    GeometryLabelConfig: LabelConfig & {
        text?: DataDrivenPropertyValueSpecification<string>;
    }

    The label drawn at the center of each geometry: its text, and how it looks.

    Type Declaration

    • Optionaltext?: DataDrivenPropertyValueSpecification<string>

      Text of the label: a string, or a MapLibre expression that evaluates to one.

      ['get', 'title']
      
      // Display feature property
      text: ['get', 'name']

      // Concatenate properties
      text: ['concat', ['get', 'name'], ' (', ['get', 'area'], ' km²)']

      // Conditional text
      text: ['case', ['has', 'label'], ['get', 'label'], '']

    Unset fields keep the defaults: the feature's title as text, size 15, bold font, and theme-adaptive colours — '#333333' text with a '#FFFFFF' halo on light map styles, the reverse on dark.

    // Simple text
    const label: GeometryLabelConfig = {
    text: ['get', 'name']
    };

    // Conditional text, larger and in white
    const conditionalLabel: GeometryLabelConfig = {
    text: ['case', ['has', 'title'], ['get', 'title'], ['get', 'id']],
    size: 18,
    color: '#FFFFFF',
    haloColor: '#000000',
    };

    // The title, restyled
    const largeLabel: GeometryLabelConfig = { size: 18 };