# mapbox-draw-expand

> Expanded development based on mapbox-gl-draw

Latest version **1.4.5** (published 2023-06-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install mapbox-draw-expand
pnpm add mapbox-draw-expand
yarn add mapbox-draw-expand
bun add mapbox-draw-expand
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.4.5 |
| Published | 2023-06-05 |
| First published | 2021-01-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 25 |
| Unpacked size | 8.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1094 |
| Author | chenyinkai |
| Maintainers | chenyinkai |
| Keywords | webgl, mapbox, draw, drawing |

## Links

- npm: https://www.npmjs.com/package/mapbox-draw-expand
- 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-draw-expand

## Dependencies (25)

- [hat](https://npm.io/package/hat.md) 0.0.3
- [turf](https://npm.io/package/turf.md) ^3.0.14
- [xtend](https://npm.io/package/xtend.md) ^4.0.1
- [@turf/center](https://npm.io/package/@turf/center.md) ^6.3.0
- [@turf/bearing](https://npm.io/package/@turf/bearing.md) ^6.3.0
- [@turf/explode](https://npm.io/package/@turf/explode.md) ^6.3.0
- [@turf/helpers](https://npm.io/package/@turf/helpers.md) ^6.3.0
- [@turf/distance](https://npm.io/package/@turf/distance.md) ^6.3.0
- [lodash.isequal](https://npm.io/package/lodash.isequal.md) ^4.2.0
- [lodash.clonedeep](https://npm.io/package/lodash.clonedeep.md) ^4.5.0
- [@turf/destination](https://npm.io/package/@turf/destination.md) ^6.3.0
- [@turf/line-segment](https://npm.io/package/@turf/line-segment.md) ^6.3.0
- [@mapbox/geojsonhint](https://npm.io/package/@mapbox/geojsonhint.md) 3.0.0
- [@mapbox/geojson-area](https://npm.io/package/@mapbox/geojson-area.md) ^0.2.1
- [@turf/line-intersect](https://npm.io/package/@turf/line-intersect.md) ^6.3.0
- [@mapbox/geojson-extent](https://npm.io/package/@mapbox/geojson-extent.md) ^0.3.2
- [@mapbox/point-geometry](https://npm.io/package/@mapbox/point-geometry.md) 0.1.0
- [@mapbox/geojson-normalize](https://npm.io/package/@mapbox/geojson-normalize.md) 0.0.1
- [@turf/transform-translate](https://npm.io/package/@turf/transform-translate.md) ^6.3.0
- [rollup-plugin-node-globals](https://npm.io/package/rollup-plugin-node-globals.md) ^1.4.0
- [@turf/boolean-point-on-line](https://npm.io/package/@turf/boolean-point-on-line.md) ^6.3.0
- [@turf/nearest-point-on-line](https://npm.io/package/@turf/nearest-point-on-line.md) ^6.3.0
- [@turf/points-within-polygon](https://npm.io/package/@turf/points-within-polygon.md) ^6.3.0
- [rollup-plugin-node-builtins](https://npm.io/package/rollup-plugin-node-builtins.md) ^2.1.2
- [@turf/point-to-line-distance](https://npm.io/package/@turf/point-to-line-distance.md) ^6.3.0

## Recent versions

- 1.4.5 (latest) — 2023-06-05
- 1.4.4 — 2022-03-23
- 1.4.3 — 2022-03-23
- 1.4.2 — 2021-07-12
- 1.4.1 — 2021-05-28
- 1.4.0 — 2021-05-27
- 1.3.6 — 2021-05-26
- 1.3.5 — 2021-05-13
- 1.3.4 — 2021-04-26
- 1.3.3 — 2021-04-26
- 1.3.2 — 2021-04-23
- 1.3.1 — 2021-04-23
- 1.3.0 — 2021-04-22
- 1.2.2 — 2021-04-15
- 1.2.1 — 2021-04-14
- … 22 more at https://npm.io/package/mapbox-draw-expand/versions

## README

# mapbox-draw-expand

[![npm version](https://badge.fury.io/js/mapbox-draw-expand.svg)](https://badge.fury.io/js/mapbox-draw-expand)

Expanded development based on [mapbox-gl-draw](github.com/mapbox/mapbox-gl-draw).

## CHANGE LOGS

### 1.3.5

FEAT: support removeLayer.

### 1.3.4 1.3.3

FIX: delete auxiliaryLine.

### 1.3.2

DOCS: update change logs.

### 1.3.1

FIX: Optimize the adsorption effect.

### 1.3.0

FEAT: support Angle Snapping.

Use this function to draw segment that is parallel, perpendicular or at precisely defined angles (30°, 45°, 60°, 90°) degrees to the base segment.

**Basic usage**

1. Activate `Draw mode` as usual
2. To select base segment:
    - click `Right mouse click` on segment you want to use as reference OR
    - move mouse that you can choose the direction of next segment to make specific angle between segments (0,30,45,90, degrees etc.).
3. Angle snapping mode will snap angle of the new segments to predefined list of angles - thus it's name

### EXPAND FUNCTIONS

- [x] In the simple_select or direct_mode, hold `Esc` to switch to simple_select mode and clear all selected features.
- [x] In the simple_select mode, hold down `shift + e` to select the feature that has an intersection with the selected feature. And hold down `shift + r` to select all.
- [x] In the direct_select mode and the seleted feature's type is LineString, when you select the first or last vertex, press and hold `shift + q` to enter the draw_line_string mode. This allows you to continue drawing the current feature.
- [x] In the simple_select mode, if some features are selected, press `ctrl + v` to paste the features, and the new features will be rendered to the position centered on the mouse position.

## NOTES

### 同层吸附说明

```js
// 进入绘制 mode 时会触发 draw.drawingInit 事件，可在此设置绘制图形的属性
map.on('draw.drawingInit', function(e) {
    Draw.setFeatureProperty(e.featureId, 'level', 1);
})

// mapbox-gl-draw 初始化时增加 adsorbFilterFunc 配置项
/**
 * 可吸附 features 过滤
 * @param {Object} nowFeature 当前绘制 feature
 * @param {Array<Object>} allAdsorbFeatures 当前鼠标位置下可吸附的 features
 * @return {Array<Object>} 返回所有可吸附的 features 集合 默认为 allAdsorbFeatures
 */
{
    ...
    adsorbFilterFunc: (nowFeature, allAdsorbFeatures) => {
        return allAdsorbFeatures.filter(v => Number(v.properties.level) === Number(nowFeature.properties.level));
    }
}
```

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