Wildhoney / Leaflet.FreeDraw

:earth_asia: FreeDraw allows the free-hand drawing of shapes on your Leaflet.js map layer – providing an intuitive and familiar UX for creating geospatial boundaries similar to Zoopla and others. Included out-of-the-box is the concaving of polygons, polygon merging and simplifying, as well as the ability to add edges and modify existing shapes.
https://freedraw.herokuapp.com/
MIT License
544 stars 103 forks source link

Draw Layer Problem #164

Closed 00ricardo closed 4 years ago

00ricardo commented 4 years ago

Hello my friend,

I am very interested in your plugin and have already managed to integrate it into my application, however, it is not working well with other plugins.

Note that when I use the tool to draw more than 1 time, the rest of my code stops working. When I say this, what I mean is that it creates a kind of layer, and leaves all other objects instantiated on the map without interaction, I can't click them. I think there has to be something with the Z-index or the drawing is occupying a much higher layer than the one that appears on the map. 1 2

PS: As I mentioned, with 1 drawing it works, with more than 1 it doesn't. Hope you can help me, thank you!

Wildhoney commented 4 years ago

Could you please use https://jsfiddle.net/0dzhs5Lg/3/ to create a quick example?

00ricardo commented 4 years ago

Hello! Here is the example (part of my code) https://jsfiddle.net/1nrfbkd6/2/

Try to click the circle and then draw. Repeat it many times and the error will appear.

00ricardo commented 4 years ago

Please, let me know if you see the example. Thank you!

Wildhoney commented 4 years ago

Thanks, yep. I see the issue in the JSFiddle, but when I added your code to the example from this repo, it seems to work fine. I can always click on the marker. I can't seem to find the difference between the two which is frustrating.

00ricardo commented 4 years ago

My friend, I came to the conclusion that the problem is not free draw. Sorry for this inconvenience. I'm using the SemiCircles plugin and it doesn't work with yours and probably others. I tested both separately and that's what I deduced. Your work is fantastic, and thanks for the replies.

Wildhoney commented 4 years ago

Ah! That's probably why I found it difficult to reproduce locally. Glad you've found it – please let me know if I can help further once you identify the actual issue with that plugin.

00ricardo commented 4 years ago

Thank you for your disposition !! I'll keep the topic open. If I find a solution I will leave it here. Thank you!

00ricardo commented 4 years ago

Hello again, sorry to bother you! But I was wondering if there is any way to know if the user drew it. To solve the problem, I'm deleting the circles and instantiating again. But I would only like to do it when the user finishes the drawing.

https://jsfiddle.net/d3w2mqp4/1/

Wildhoney commented 4 years ago

Yep, you can use:


freeDraw.on('markers', event => {
    console.log('Added, removed or edited polygons!');
});
00ricardo commented 4 years ago

Good Morning! Thank you very much, I completely forgot about this event! Everything is working as intended , 1000 thanks! I'll close the post.