mirror of
https://github.com/Leaflet/Path.Drag.js.git
synced 2025-08-15 23:29:37 +00:00
c2417c43c68c1641707983c3a05a9728490f773b
Path.Drag.js
Add dragging capability to Leaflet path (Polygon, Polyline, Rectangle, Circle, CircleMarker…).
Example
Installation
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.
Description
Languages
JavaScript
61.5%
HTML
38.5%