Leaflet / Leaflet.draw

Vector drawing and editing plugin for Leaflet
https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html
MIT License
1.97k stars 992 forks source link

Leaflet Draw Saving #726

Open ZachBolton1995 opened 7 years ago

ZachBolton1995 commented 7 years ago

Hi

I'm developing a simple Leaflet js application, designed to allow users to draw using the Leaflet.draw plugin. Then what I'm trying to allow is users to export and save the drawn shapes on the map as a shapefile. This is where I'm having difficulty, in what is the best way to save leaflet.draw shapes in a sufficient way. is this even possible to do? Any help would be appreciated. Thanks

ddproxy commented 7 years ago

Hey @ZachBolton1995 ! You can get all the shapes off the drawn layer an export those shapes into GeoJSON. You will have to use another library to save that GeoJSON to shapefile format, however. There are plenty of options you may find with a google search, so I won't posit an opinion on which library to use.

encleadus commented 7 years ago

Regards to saving to GeoJSON. I experienced a bug in the drawing tool and appear in two cases for me. The bug is basically in the drawing tool edit mode on touch devices, the JSON.stringify(drawnItems.toGeoJSON()) , no effect on the stringified text. The expected behavior is on draw edited JSON.stringify value should change but nothing happening during polygon edit, rectangle edit. Only the rectangle move works.

ddproxy commented 7 years ago

Can you make a jsfiddle of this?