# @mapbox/mapbox-gl-draw

> A drawing component for Mapbox GL JS

Latest version **1.5.2** (published 2026-09-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install @mapbox/mapbox-gl-draw
pnpm add @mapbox/mapbox-gl-draw
yarn add @mapbox/mapbox-gl-draw
bun add @mapbox/mapbox-gl-draw
```

## Health

**Score 73/100 (B)** — status: active.

Positive: has types package; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.5.2 |
| Published | 2026-09-14 |
| First published | 2016-12-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/mapbox__mapbox-gl-draw) |
| Module format | ESM + CommonJS |
| Node | ^18.0.0 \|\| >=20.0.0 |
| Dependencies | 6 |
| Unpacked size | 911.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1088 |
| Author | mapbox |
| Maintainers | mapbox-npm-01, mapbox-npm-02, mapbox-npm-07, mapbox-npm-03, mapbox-npm-04, mapbox-npm-09, mapbox-npm-05, mapbox-npm-06, mapbox-npm-08, mapbox-npm-advanced-actions, mapbox-npm-ci, mapbox-npm, mapbox-admin, mapbox-machine-user, mbx-npm-ci-staging, mbx-npm-ci-production, mbx-npm-01-production, mbx-npm-02-production, mbx-npm-03-production, mbx-npm-04-production, mbx-npm-05-production, mbx-npm-06-production, mbx-npm-07-production, mbx-npm-08-production, mbx-npm-09-production, mbx-npm-02-staging, mbx-npm-advanced-actions-staging, mbx-npm-advanced-actions-production |
| Keywords | webgl, mapbox, draw, drawing |

## Links

- npm: https://www.npmjs.com/package/@mapbox/mapbox-gl-draw
- Repository: https://github.com/mapbox/mapbox-gl-draw
- Issues: https://github.com/mapbox/mapbox-gl-draw/issues
- npm.io page: https://npm.io/package/@mapbox/mapbox-gl-draw

## Dependencies (6)

- [nanoid](https://npm.io/package/nanoid.md) ^6.0.0
- [fast-deep-equal](https://npm.io/package/fast-deep-equal.md) ^3.1.3
- [@turf/projection](https://npm.io/package/@turf/projection.md) ^7.2.0
- [@mapbox/geojson-area](https://npm.io/package/@mapbox/geojson-area.md) ^0.2.2
- [@mapbox/point-geometry](https://npm.io/package/@mapbox/point-geometry.md) ^1.1.0
- [@mapbox/geojson-normalize](https://npm.io/package/@mapbox/geojson-normalize.md) ^0.0.1

## Recent versions

- 1.5.2 (latest) — 2026-09-14
- 1.4.4-alpha.db018ed (dev) — 2024-07-31
- 1.2.0-beta.1 (next) — 2020-01-07
- 1.5.1 — 2025-11-03
- 1.5.0 — 2024-12-04
- 1.4.3 — 2023-09-21
- 1.4.2 — 2023-06-28
- 1.4.1 — 2023-02-14
- 1.4.0 — 2023-01-31
- 1.3.0 — 2021-05-20
- 1.2.2 — 2021-02-25
- 1.2.1 — 2021-02-03
- 1.2.0 — 2020-07-13
- 1.1.2 — 2019-05-22
- 1.1.1 — 2018-11-26
- … 22 more at https://npm.io/package/@mapbox/mapbox-gl-draw/versions

## README

# @mapbox/mapbox-gl-draw

![Build Status](https://github.com/mapbox/mapbox-gl-draw/actions/workflows/main.yml/badge.svg)

Adds support for drawing and editing features on [mapbox-gl.js](https://www.mapbox.com/mapbox-gl-js/) maps. [See a live example here](https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-draw/)

**Requires [mapbox-gl-js](https://github.com/mapbox/mapbox-gl-js).**

**If you are developing with `mapbox-gl-draw`, see [API.md](https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/API.md) for documentation.**

### Installing

```
npm install @mapbox/mapbox-gl-draw
```

Draw ships with CSS, make sure you include it in your build.

### Usage in your application

#### JavaScript

**When using modules**

```js
import mapboxgl from 'mapbox-gl';
import MapboxDraw from "@mapbox/mapbox-gl-draw";
```

**When using a CDN**

```html
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.4.3/mapbox-gl-draw.js'></script>
```

#### CSS

**When using modules**
 ```js
import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css'
 ```

**When using CDN**
```html
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.4.3/mapbox-gl-draw.css' type='text/css' />
```

### Typescript

Typescript definition files are available as part of the [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mapbox__mapbox-gl-draw) package.

```
npm install @types/mapbox__mapbox-gl-draw
```

### Example usage

```js
mapboxgl.accessToken = 'YOUR_ACCESS_TOKEN';

var map = new mapboxgl.Map({
  container: 'map',
  style: 'mapbox://styles/mapbox/streets-v12',
  center: [40, -74.50],
  zoom: 9
});

var Draw = new MapboxDraw();

// Map#addControl takes an optional second argument to set the position of the control.
// If no position is specified the control defaults to `top-right`. See the docs
// for more details: https://docs.mapbox.com/mapbox-gl-js/api/#map#addcontrol

map.addControl(Draw, 'top-left');

map.on('load', function() {
  // ALL YOUR APPLICATION CODE
});
```

https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-draw/

### See [API.md](https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/API.md) for complete reference.

### Enhancements and New Interactions

For additional functionality [check out our list of custom modes](https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/MODES.md#available-custom-modes).

Mapbox Draw accepts functionality changes after the functionality has been proven out via a [custom mode](https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/MODES.md#creating-modes-for-mapbox-draw). This lets users experiment and validate their mode before entering a review process, hopefully promoting innovation. When you write a custom mode, please open a PR adding it to our [list of custom modes](https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/MODES.md#available-custom-modes).

### Developing and testing

Install dependencies, build the source files and crank up a server via:

```
git clone git@github.com:mapbox/mapbox-gl-draw.git
npm ci
npm start & open "http://localhost:9967/debug/?access_token=<token>"
```

### Testing

```
npm run test
```

### Publishing

To publish new version on GitHub and NPM, create pull request with version bump and update changelog. After PR is merged, run the following commands on the commit that was merged to `main` branch:

```
git tag v{x.y.z}
git push origin v{x.y.z}
```

Create a release on GitHub with the same version number and changelog after successful run of `.github/workflows/npm-release.yml`

To CDN:

```
# make sure you are authenticated for AWS
git checkout v{x.y.z}
npm ci
npm run prepublishOnly
aws s3 cp --recursive --acl public-read dist s3://mapbox-gl-js/plugins/mapbox-gl-draw/v{x.y.z}
```

Update the version number in [the GL JS example](https://github.com/mapbox/mapbox-gl-js/blob/publisher-production/docs/pages/example/mapbox-gl-draw.html).

### Naming actions

We're trying to follow standards when naming things. Here is a collection of links where we look for inspiration.

- https://turfjs.org
- https://shapely.readthedocs.io/en/latest/manual.html

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