Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Leaflet.draw extension #266

JamesPiggles opened this Issue Jan 17, 2014 · 4 comments


None yet
4 participants

Hello there,
I'm currently trying to extend leaflet.draw to include freehand polygons. Letting the user draw a free hand shape onto the map and then converting it to a simplified polygon of, say, no more than 20 sides.

I'm considering using a html 5 canvas to map the co-ordinates of the user's dragging and an as yet undertermined algorithm to simplify the points from thousands to ~20 or so. Then passing this back to leaflet polygon function to render it on the map.

I'm intending to contribute back to the plugin if my extension is successful.

I was wondering if anyone had attempted this before and had any thoughts on implementation?


Hello again!
I've managed to make a neat plugin for leaflet.draw that allows freehand polygons to be drawn. However, it depends on the leaflet html5 canvas layer plug in for the initial drawing. This is the only external dependency and all the simplification etc is contained within the freehand draw handler. The plug in used is: https://github.com/CartoDB/Leaflet.CanvasLayer

I would like to push this extension to the leaflet.draw code base and was wondering if you had any preferences on how to go about this?


jacobtoye commented Feb 4, 2014

Hi @JamesPiggles, adding major features like this to the codebase is a hard task. What I usually do is either leave the issue or pull open and direct people interested there. We could add a section to the readme that lists notable extensions.

Gmitry commented Apr 6, 2014

Thank you for really good work with the Leaflet Draw. It had really been great to have a "freehand" draw function e.g. based on configurable length increment or optionally a time increment to optimize the number of nodes along such freehand drawn lines.

To add a configurable parameter function for users as part of the menu-bar had as well been great.

Then as well could set user named layers for the drawn contents as well as a parameter for spline/quad control settings of the line on the particular layer (see some similar to the spline setting in kinematicjs lib). Other parameters today in the developer environment could then as well been lifted to the same user config.

nzifnab commented Jul 28, 2014

@JamesPiggles where is the code to your draw extension? You should link to it from here. I can't find it on your leaflet fork from your github page, and I'm looking for functionality similar to that as opposed to the click-click-click to draw polygons that Leaflet.Draw currently supports.

@jacobtoye jacobtoye closed this Aug 1, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment