Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to draw more than one shape #271

Open
jeancochrane opened this issue Jan 29, 2020 · 3 comments
Open

Allow users to draw more than one shape #271

jeancochrane opened this issue Jan 29, 2020 · 3 comments

Comments

@jeancochrane
Copy link

I'm using the forms and draw plugins to allow users to draw shapes for a model attribute and save them to the database. I'm storing the shapes as GeometryCollections, so I'd like to allow users to draw more than one shape on the map. However, it seems like the forms and draw plugins are configured to only allow users to draw one shape on the map (i.e. if a user places a marker on the map, and then places another marker, the first marker will be deleted from the map). Is there any way to customize this behavior? If not, what part of the code would I need to modify to support adding multiple shapes to one map?

@simon-tarr
Copy link

Hi @jeancochrane,

I'm hoping you could help me! I've previously built an R Shiny app using leaflet which takes a user's drawn input and uses it for various calculations. I've recently been dabbling with porting my app to Django but, as I'm so new to the framework, I can't yet take a user's polygon input from Leaflet JS and pass it back into a database/backend (for further manipulation - e.g. using the user polygon to crop a raster). Do you have any pointers for how I can learn your method of saving a user shape to your Django DB? Did you follow any tutorials online, or did you kinda just make it up as you went along, based on your prior knowledge?

Sorry I can't help with your actual question above!

Many thanks
Simon

@jeancochrane
Copy link
Author

No worries @simon-tarr! I can't quite remember what docs I was referencing when I opened this issue, but you can see the custom form I wound up creating here: https://github.com/fpdcc/document-search/blob/a466bfd63ee8aa2d53dc3103af0a2d51547ad0c2/docsearch/forms.py#L16-L42

And here's a link to the corresponding template for the form: https://github.com/fpdcc/document-search/blob/master/docsearch/templates/docsearch/licenses/form.html

Hope this helps!

@simon-tarr
Copy link

You're a star, thank you! I'll take a good look at these...hopefully I can wrap my brain around it all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants