https://github.com/leaflet/path.drag.js
Add dragging capability to Leaflet paths.
https://github.com/leaflet/path.drag.js
leaflet leaflet-plugin
Last synced: 7 months ago
JSON representation
Add dragging capability to Leaflet paths.
- Host: GitHub
- URL: https://github.com/leaflet/path.drag.js
- Owner: Leaflet
- Created: 2016-07-03T21:35:18.000Z (almost 10 years ago)
- Default Branch: gh-pages
- Last Pushed: 2018-07-27T10:31:20.000Z (over 7 years ago)
- Last Synced: 2025-05-31T04:13:47.443Z (11 months ago)
- Topics: leaflet, leaflet-plugin
- Language: JavaScript
- Size: 11.7 KB
- Stars: 27
- Watchers: 6
- Forks: 14
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Path.Drag.js
Add dragging capability to Leaflet path (Polygon, Polyline, Rectangle, Circle, CircleMarker…).
## Example
- [simple example](http://Leaflet.github.io/Path.Drag.js/example/index.html)
- [huge polygon example](http://Leaflet.github.io/Path.Drag.js/example/russia.html)
- [canvas example](http://Leaflet.github.io/Path.Drag.js/example/canvas.html)
## Installation
**This library requires Leaflet version 1.0 or above**
Include `Path.Drag.js` in your javascript files (after including Leaflet itself).
It's available via NPM:
npm install leaflet.path.drag
## Usage
A `dragging` handler will be attached to the paths instance of your map.
To enable dragging, just do:
layer.dragging.enable()
To disable:
layer.dragging.disable()
If you want a path to be draggable as soon as it's added to map, add
`draggable: true` to its options:
const layer = L.polygon([…], {draggable: true})
## Alternatives:
- https://github.com/w8r/Leaflet.Path.Drag: use it if you want to drag very big path
with many vertices.