Open germanjoey opened 9 years ago
I have a running leaflet v1 with the draw plugin (that special branch). It required some code changes in the draw plugin itself to work, but it does work.
The only problem is when drawing things (best noticed with polygons) you can see the bounding box. Parts of the polygon are hidden until you complete the shape. It could be that I do something wrong but this is what I noticed.
What sorts of code changes did you need to make? Could you post them to a gist or somesuch?
I took the code from the leaflet-master branch. One of the problems I noticed was this one: https://github.com/Leaflet/Leaflet.draw/issues/450
The rest of the problems is just adding it, debugging it, and see where it fails. ( I can't remember all code changes I made, but there weren't a lot. )
Uh, I guess I'll just wait for an official release...
I'm in the same boat as you. We need to use leaflet 1.0 in our production environment (and it works fine) but leaflet.draw (or any other library that enables me to edit polygons / geoJson layers that I've tried) has lots of issues with it.
Does it work properly with the polygon being on a canvas layer?
@codeofsumit I did a quick check on with you library, it has the same problem for canvas: http://playground-leaflet.rhcloud.com/sem/1/edit?html,output
See the playground thing. The draw plugin has the same problem as you library.
@Brutusn we're not using canvas but I'll have a look - thanks for the playground snipped!
I made a issue on the main leaflet page, as I think that the problem is in leaflet itself.
I have beta 2 installed, and I got the /dist copy from here: https://github.com/Leaflet/Leaflet.draw/tree/leaflet-master,
What I see is that I can draw, but the edit controls are grey'ed out, and after I finish a line or polygon then it disappears. Is that what others are experiencing?
The /dist copy is not updated with the latest code change (see the change date, 2 year ago).
I'll attach the version I use. It also contains a small fix kind of thing (line 398) To make polygons draw correctly again (editting is still not correct). leaflet.draw-src.txt
Change the extension to js again.. otherwise GitHub didn't like it.
@Brutusn, thanks muchly this is beyond what I expected.
However, I changed the extension, did a hard-reload in Chrome, and even put a break point at your Bart fix. What I am seeing is the same effect. I see it hits your
this._poly.redraw();
But what I see is that the poly will draw till the last point (same with line) but when you close or finish the line, the object disapears. I am using
<script>L_PREFER_CANVAS = true;</script>
This demo, does work fine: http://leaflet.pm.kaumgeschlafen.com/demo/
@DrYSG The demo page from the leaflet.pm doesn't use a canvas layer.
The L_PREFER_CANVAS is not used anymore in leaflet 1 (as far as I can see.) It's now an option to add when initializing the map: var map = L.map('map', {preferCanvas: true});
Also for my test I did not try to fix it for non canvas layers (I don't use those anyway). I don't have the disappearing shape in my place.
I found the problem with my disappearing features. I have your code now working in Beta2, Drawing is working fine, So is does edit and save. But oddly enough, the cancel is not working. I don't know if this is a beta issue. I put the problem up in stack-overflow: http://stackoverflow.com/questions/33877116/leaflet-draw-does-not-cancel-properly
@Brutusn My experimentation is showing two problems with Leaflet.draw with the Beta 2. (but neither of these problems exist in 7.7. Does anyone have more to add?
allowIntersection: false,
showArea: true,
drawError: {
color: '#e1e100',
timeout: 1000,
message: '<strong>Oh snap!<strong> you can\'t draw that!'
}
@DrYSG There are still a few problem left over..
But to aswer yours:
1) I don't have the problem for boxes and circles.. I can't really cancel anyway. But the delete last vertex was a problem I had.. But I solved it with this commit: https://github.com/Leaflet/Leaflet.draw/commit/8943d99649bd8059a28fa38571392325a9ce5fea (the _spliceLatLngs)
2) This commit fixes the allow intersection. https://github.com/Leaflet/Leaflet.draw/commit/a7aca2553e52943fe671d40f0a1e30dd7a178209 It doesn't seem to work for editting the polygon though.
P.S.: It's annoying but creating those "fiddles" is good to do, it's easy to spot the error: For leaflet this one is very nice: https://playground-leaflet.rhcloud.com
I've stage this issue for 0.4.0 to be released as full Leaflet 1.x support. There are some API changes that need to be fixed and L@1.x is not final yet - although it's close!
I spent the weekend refactoring some of the internals to successfully work with both 0.7.x and 1.0.0-rc3
Is it good to go? I'm starting a new project and would like to use Leaflet v1.0, but I also need Leaflet draw. Thanks.