# @types/mapbox__mapbox-gl-traffic

> TypeScript definitions for @mapbox/mapbox-gl-traffic

Latest version **1.0.3** (published 2026-02-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/mapbox__mapbox-gl-traffic
pnpm add @types/mapbox__mapbox-gl-traffic
yarn add @types/mapbox__mapbox-gl-traffic
bun add @types/mapbox__mapbox-gl-traffic
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2026-02-21 |
| First published | 2022-04-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51438 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/mapbox__mapbox-gl-traffic
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mapbox__mapbox-gl-traffic
- npm.io page: https://npm.io/package/@types/mapbox__mapbox-gl-traffic

## Dependencies (2)

- [@types/node](https://npm.io/package/@types/node.md) *
- [@types/mapbox-gl](https://npm.io/package/@types/mapbox-gl.md) <3.5

## Recent versions

- 1.0.3 (latest) — 2026-02-21
- 1.0.2 (ts5.1) — 2023-11-07
- 1.0.0 (ts4.0) — 2022-04-14
- 1.0.1 — 2023-10-18

## README

# Installation
> `npm install --save @types/mapbox__mapbox-gl-traffic`

# Summary
This package contains type definitions for @mapbox/mapbox-gl-traffic (https://github.com/mapbox/mapbox-gl-traffic).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mapbox__mapbox-gl-traffic.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mapbox__mapbox-gl-traffic/index.d.ts)
````ts
/// <reference types="mapbox-gl" />
/// <reference types="node" />

export as namespace MapboxTraffic;
export = MapboxTraffic;

declare class MapboxTraffic {
    /**
     * Create a new [Mapbox GL JS plugin](https://www.mapbox.com/blog/build-mapbox-gl-js-plugins/) that allows you to hide and show
     * traffic layers in your map and an optional toggle button.
     *
     * @param options - Options to configure the plugin.
     */
    constructor(options?: MapboxTraffic.Options);
    _hasTraffic(): boolean;
    _hideTraffic(): void;
    _showTraffic(): void;
    onAdd(map: mapboxgl.Map): HTMLDivElement;
    onRemove(): void;
    render(): void;
    /**
     * Toggle visibility of traffic layer.
     */
    toggleTraffic(): void;
}

declare namespace MapboxTraffic {
    /** Options to configure the `MapboxTraffic` plugin. */
    interface Options {
        /**
         * Show or hide traffic overlay by default.
         *
         * @default false
         */
        showTraffic?: boolean;
        /**
         * Show a toggle button to turn traffic on and off.
         *
         * @default true
         */
        showTrafficButton?: boolean;
        /**
         * The traffic source regex used to determine whether a layer displays traffic or not.
         *
         * @default /mapbox-traffic-v\d/
         */
        trafficSource?: RegExp;
    }
}

````

### Additional Details
 * Last updated: Sat, 21 Feb 2026 05:22:18 GMT
 * Dependencies: [@types/mapbox-gl](https://npmjs.com/package/@types/mapbox-gl), [@types/node](https://npmjs.com/package/@types/node)

# Credits
These definitions were written by [Niek van Bennekom](https://github.com/niekvb).

---
_Source: https://npm.io/package/@types/mapbox__mapbox-gl-traffic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
