Yohan Boniface a15c06a3d7 Use path center as event.latlng for move event
The move event is listened by popup and tooltip when attached to
a layer, so we want to keep them centered, not to follow the mouse
position while dragging.

fix Leaflet/Leaflet.Editable#140
2017-08-09 09:44:33 +02:00
2016-07-03 23:43:28 +02:00
2016-07-16 11:58:58 +04:30

Path.Drag.js

Add dragging capability to Leaflet path (Polygon, Polyline, Rectangle, Circle, CircleMarker…).

Example

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:

Description
Add dragging capability to Leaflet paths.
Readme 47 KiB
Languages
JavaScript 61.5%
HTML 38.5%