leaflet-craft
TypeScript icon, indicating that this package has built-in type declarations

4.1.7 • Public • Published

Leaflet-Craft

DEMO: https://sagarpreet-chadha.github.io/Leaflet-Craft/example/index

npm version


npm : https://www.npmjs.com/package/leaflet-craft

Extends https://github.com/Wildhoney/Leaflet.FreeDraw made by WildHoney and adds following functionalities to it:

  1. Adds Undo-Redo feature to Polygons.
Screenshot 2019-10-07 at 1 35 47 AM
  1. Adds Delete 1 marker feature by right clicking it.

  2. Adds Delete multiple markers by drawing circle around them :)

Screenshot 2019-10-07 at 1 42 05 AM
  1. Adds Control Bar to easily change MODES - Create, Edit, Delete Polygon, Delete 1 Marker, Delete multiple Markers.
Screenshot 2019-10-07 at 1 48 57 AM
  1. Calculates AREA (in metre square) of polygon which changes dynamically on editing the polygon. Stored with key polygonArea in each polygon's leaflet object.

export const polygonArea = Symbol('freedraw/polygonArea') We use TURF Area function to calculate the area.

  1. Add Hooks:

We can subscribe to following Event listeners and can pass a callback function to be executed. Callback function can be asynchronous as well, also the return value should be TRUE to continue the event (create/edit/delete) else if your callback function returns False then that event is forfeited. This is implemented by ES6 promise.

  • Polygon created: Started
  • Polygon created: Ended
  • Polygon edit: Started
  • Polygon edit: Ended
  • Polygon delete: Started
  • Polygon delete: Ended

Work in PROGRESS:

  1. Conversion to Typescript.
  2. Adding functionality to create Polygon via clicking (similar to Leaflet.Draw).
  3. Extending React-Leaflet to support React apps.

ABOUT:

Thank you @wildhoney, @ankeetmaini and other contributors ❤️ . This library is actively maintained by @sagarpreet-chadha .

Package Sidebar

Install

npm i leaflet-craft

Weekly Downloads

2

Version

4.1.7

License

MIT

Unpacked Size

11.9 MB

Total Files

33

Last publish

Collaborators

  • sagarpreet