Leaflet / Leaflet.draw

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

What's the status of the Leaflet v1.0 branch of Leaflet.draw? #455

Open germanjoey opened 9 years ago

germanjoey commented 9 years ago

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.

Brutusn commented 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.

germanjoey commented 9 years ago

What sorts of code changes did you need to make? Could you post them to a gist or somesuch?

Brutusn commented 9 years ago

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. )

germanjoey commented 9 years ago

Uh, I guess I'll just wait for an official release...

codeofsumit commented 9 years ago

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.

codeofsumit commented 8 years ago

@germanjoey as we couldn't wait anymore to have leaflet 1.0 covered here, I created another plugin specifically for leaflet 1.0. I tested it with L.polygon and L.geoJson and editing the coordinates works fine.

Plugin | Demo

Brutusn commented 8 years ago

Does it work properly with the polygon being on a canvas layer?

Brutusn commented 8 years ago

@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.

codeofsumit commented 8 years ago

@Brutusn we're not using canvas but I'll have a look - thanks for the playground snipped!

Brutusn commented 8 years ago

I made a issue on the main leaflet page, as I think that the problem is in leaflet itself.

https://github.com/Leaflet/Leaflet/issues/4018

DrYSG commented 8 years ago

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?

Brutusn commented 8 years ago

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.

DrYSG commented 8 years ago

@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/

Brutusn commented 8 years ago

@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.

DrYSG commented 8 years ago

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

DrYSG commented 8 years ago

@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?

  1. Start drawing any polygon, box, circle, etc, and you get an error when canceling; Details at: http://stackoverflow.com/questions/33877116/leaflet-draw-does-not-cancel-properly
  2. Set allowIntersection: false and while there is no error, no message or error draw color is shown.
                        allowIntersection: false,
                         showArea: true,
                         drawError: {
                             color: '#e1e100',
                             timeout: 1000,
                             message: '<strong>Oh snap!<strong> you can\'t draw that!'
                         }
Brutusn commented 8 years ago

@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

ddproxy commented 8 years ago

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!

chugcup commented 8 years ago

I spent the weekend refactoring some of the internals to successfully work with both 0.7.x and 1.0.0-rc3

See https://github.com/Leaflet/Leaflet.draw/pull/596