Add rotate functionality to the Leaflet.Draw plugin
npm install leaflet-draw-rotateALPHA leaflet plugin - adds rotate functionality to the Leaflet.Draw plugin by binding it with a custom version of the Leaflet.Path.Transform plugin.
- [x] Rotate rectangle
- [ ] Rotate polygon
- [ ] Rotate polyline
``javascript
// import peer dependencies
import 'leaflet';
import 'leaflet-draw';
// import plugin, then rotate bindings for each required geomtry type
import 'leaflet-draw-rotate';
import '/path/to/dist/Edit.Rectangle.Rotate.js';
// optional - configure transform options
L.Edit.Rectangle.prototype.setOptions({ uniformScaling: false });
// init leaflet-draw.. (see demo for detailed example)
`
Options should be applied via the edit handler's prototype setOptions function (see above example).
- options.handlerOptions - <Path_options> - edge markers options
- options.boundsOptions - <Polyline_options> - bounding rectangle options
- options.rotateHandleOptions - <Polyline_options> - rotation handle line styles
- options.handleLength - Int - Length of the rotation handle in pixels. Defaults to 20.
- options.rotation - Boolean - Enable/disable rotation. Default trueoptions.scaling
- - Boolean - Enable/disable scaling. Default trueoptions.uniformScaling
- - Boolean - Use uniform scaling (maintain aspect ratio). Default trueoptions.scaleRounding
- - Int - Decimal rounding value to use when matching non-uniform drag handles (can use this if you encounter #5). Default 4
Following events are fired on the transformed layer
- rotatestart, rotate, rotateend - { rotation: scalestart
- , scale, scaleend - { scale: transformstart
- , transform, transformed - { rotation: ..., scale: ..., matrix:
If you have changed the geometry of the transformed layer and want the tool to reflect the changes, use:
`js`
// you have changed the geometry here
layer.setLatLngs([...]);
// and want to update handlers:
layer.transform.reset();
`javascript``
npm install
npm run build
[npm-image]: https://badge.fury.io/js/leaflet-draw-rotate.svg
[npm-url]: https://www.npmjs.com/package/leaflet-draw-rotate
[npm-downloads-image]: https://img.shields.io/npm/dt/leaflet-draw-rotate.svg