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

    Type Alias TrafficAreaAnalyticsModuleConfig

    TrafficAreaAnalyticsModuleConfig: MapModuleCommonConfig & {
        activeMetric?: AreaAnalyticsMetricKey;
        beforeLayerConfig?: AreaAnalyticsBeforeLayerConfig;
        displayMode?: AreaAnalyticsDisplayMode;
        layers?: TrafficAreaAnalyticsLayersConfig;
        metrics?: Partial<
            Record<AreaAnalyticsMetricKey, AreaAnalyticsMetricConfig>,
        >;
        regionPolygon?: AreaAnalyticsRegionPolygonConfig;
        visible?: boolean;
    }

    Configuration for the Traffic Area Analytics visualization module.

    Type Declaration

    • OptionalactiveMetric?: AreaAnalyticsMetricKey

      The metric that drives color and extrusion height.

      'congestionLevel'
      
    • OptionalbeforeLayerConfig?: AreaAnalyticsBeforeLayerConfig

      Where the analytics layers sit in the map's layer stack, for all display modes or per mode.

    • OptionaldisplayMode?: AreaAnalyticsDisplayMode

      Visualization mode.

      'hexgrid-3d'
      
    • Optionallayers?: TrafficAreaAnalyticsLayersConfig

      MapLibre overrides for the heatmap, the cells of each grid and the region boundary. A layer hidden through its entry's layout.visibility stays hidden in its display mode.

    • Optionalmetrics?: Partial<Record<AreaAnalyticsMetricKey, AreaAnalyticsMetricConfig>>

      Per-metric visualization configuration (palette or colour stops, height, filters).

      Metrics not listed here fall back to defaults (the trafficLight palette, metric-dependent height scale). updateConfig replaces this whole record, so to change one metric and keep the others' settings, use setPalette, setColorStops, setHeight or setFilters with that metric.

    • OptionalregionPolygon?: AreaAnalyticsRegionPolygonConfig

      Display options for the region polygon boundary drawn alongside the analytics data.

    • Optionalvisible?: boolean

      Whether the area analytics layers are visible.

      true
      

    activeMetric sets the active metric, 'congestionLevel' by default. Per-metric style settings (palette or colour stops, height, filters) sit under metrics, keyed by AreaAnalyticsMetricKey. So you can pre-configure multiple metrics independently and switch between them at runtime with updateConfig({ activeMetric }).

    const config: TrafficAreaAnalyticsModuleConfig = {
    displayMode: 'hexgrid-3d',
    activeMetric: 'congestionLevel',
    metrics: {
    congestionLevel: {
    palette: 'heat',
    height: { maxMeters: 80, scaleMode: 'predefinedRange' },
    filters: { min: 10 },
    },
    speed: {
    colorStops: {
    scaleMode: 'raw',
    stops: [
    { value: 0, color: '#e03030' },
    { value: 60, color: '#f5a623' },
    { value: 120, color: '#2dc653' },
    ],
    },
    },
    },
    };