Skip to content

🌏 Extends Leaflet.FreeDraw and gives extended features like Undo-Redo, deleting markers,dynamic area calculation of polygons ,various hooks/events and in-build control bars, etc. 🔆

License

Notifications You must be signed in to change notification settings

sagarpreet-chadha/Leaflet-Craft

 
 

Repository files navigation

Leaflet-Craft

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 .

About

🌏 Extends Leaflet.FreeDraw and gives extended features like Undo-Redo, deleting markers,dynamic area calculation of polygons ,various hooks/events and in-build control bars, etc. 🔆

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 94.0%
  • CSS 5.5%
  • HTML 0.5%