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

    Type Alias GeometryLabelConfig

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

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

    Type Declaration

    • Optionaltitle?: DataDrivenPropertyValueSpecification<string>

      The label's text, as a string or a MapLibre expression that evaluates to one.

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

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

      // Conditional text
      title: ['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 and the reverse on dark.

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

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

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