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

Polyline 'edit' event does not fire on touch devices #604

Open nhinze opened 8 years ago

nhinze commented 8 years ago

With Leaflet-draw 0.3.2, the 'edit' event does not fire on iOS simulator with iOS 9.3. It works fine on desktop.

How to reproduce:

        polyline.on('edit', function() {
            console.log('Polyline was edited!');
        });
nhinze commented 8 years ago

Neither does draw:editvertex

    map.on('draw:editvertex', function (e) {
      console.log('draw:editvertex');
    });
nhinze commented 8 years ago

LL 0.7.7

The events fire fine when adding or removing points along the polyline. It's when dragging a point that it does not work.

nhinze commented 8 years ago

I noticed that the events fire correctly when testing on Chrome and using the mobile device touch simulator in the Dev tools. However, the events do not fire on iOS or Android. From some online research, it seems that the touchend event is a bit unreliable. Hopefully a workaround can be found.

nhinze commented 8 years ago

I just tested Leaflet-draw 0.4 and I can report the following:

z0d14c commented 7 years ago

@nhinze Hi, did you ever come to any sort of resolution for this issue? I'm running into some problems with iOS/Android editing and I think its the same problem. I'm about to dig into the code but if you've already found a solution then I'd like to get a PR together and hopefully get it merged into master.

z0d14c commented 7 years ago

I found that the event fires for draw:edited but that the layers array is empty. This makes it difficult to persist changes to a server.

z0d14c commented 7 years ago

edited flag is not being toggle appropriately on dragend

nhinze commented 7 years ago

I never found a fix. I think the problem is at LL level. Touch end does not get fired for some reason.

z0d14c commented 7 years ago

I have a fix for it; basically just comment out the if (leaflet.edited) check in the save function for EditToolbar.Edit. This is appropriate for our project but I'm guessing a deeper fix will be necessary to correct the underlying issue with touchscreens. The fix is present in the master branch of z0d14c/Leaflet.draw