# leaflet-path-drag

> Drag functionality for Leaflet vector layers

Latest version **1.9.5** (published 2024-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install leaflet-path-drag
pnpm add leaflet-path-drag
yarn add leaflet-path-drag
bun add leaflet-path-drag
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.9.5 |
| Published | 2024-02-17 |
| First published | 2015-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 29 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 110 |
| Author | Alexander Milevski |
| Maintainers | w8r |
| Keywords | leaflet, path, polyline, drag, polygon |

## Links

- npm: https://www.npmjs.com/package/leaflet-path-drag
- Repository: https://github.com/w8r/Leaflet.Path.Drag
- Homepage: https://github.com/w8r/Leaflet.Path.Drag#readme
- Issues: https://github.com/w8r/Leaflet.Path.Drag/issues
- npm.io page: https://npm.io/package/leaflet-path-drag

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.9.5 (latest) — 2024-02-17
- 0.7.7 (compat) — 2016-09-28
- 1.9.4 — 2024-02-15
- 1.8.0-beta.3 — 2022-07-12
- 1.8.0-beta.2 — 2022-07-12
- 1.8.0-beta.1 — 2022-07-12
- 1.0.7 — 2017-07-03
- 1.1.0 — 2017-06-29
- 1.0.6 — 2016-12-04
- 1.0.5 — 2016-12-04
- 1.0.2 — 2016-11-25
- 1.0.1 — 2016-09-28
- 1.0.0-beta.11 — 2016-09-23
- 0.1.16 — 2016-09-01
- 1.0.0-beta.10 — 2016-07-01
- … 23 more at https://npm.io/package/leaflet-path-drag/versions

## README

# L.Path.Drag

[![npm version](https://badge.fury.io/js/leaflet-path-drag.svg)](http://badge.fury.io/js/leaflet-path-drag)

Drag handler for [Leaflet](https://github.com/leaflet/leaflet) vector features.
It adds dragging API and events of `L.Marker` to `L.Polygon` and `L.Polyline`.

If you are looking for this functionality combined with [Leaflet.draw](https://github.com/leaflet/Leaflet.draw), take a look at [Leaflet.draw.drag](http://github.com/w8r/Leaflet.draw.drag) and [Leaflet.Editable.Drag](https://github.com/w8r/Leaflet.Editable.Drag).

## [Demo](https://w8r.github.io/Leaflet.Path.Drag)

## Usage

```javascript
<script src="path/to/leaflet/"></script>
<script src="path/to/L.Path.Drag.js"></script>
...
var polygon = new L.Polygon([...], { draggable: true }).addTo(map);
// you can use the drag events just like with markers
polygon
    .on('dragstart', onDragStart)
    .on('drag',      onDrag)
    .on('dragend',   onDragEnd);
```

with browserify

```
npm install leaflet-path-drag
...

require('leaflet');
var handler = require('leaflet-path-drag');
```

Requires Leaflet@1.1.x

For Leaflet@0.7.x support use code from `leaflet-0.7` branch

#### Enable/disable dragging

```js
var polygon = new L.Polygon([...], { draggable: true }).addTo(map);
polygon.dragging.enable();
polygon.dragging.disable();
```

## Info

It uses matrix transforms on SVG/VML paths, so part of it(`src/L.Path.Transform`) could be used for different transformations - skew/scale/etc - but you have to provide coordinates projection and handling yourself.

VML matrix transform tested in IE8, it has rendering glitches, but what can you expect.

## License

The MIT License (MIT)

Copyright (c) 2015 Alexander Milevski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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