makinacorpus / Leaflet.Snap

Enables snapping of draggable markers to polylines and other layers
https://makinacorpus.github.io/Leaflet.Snap/
MIT License
198 stars 69 forks source link

Snapping while editing with leaflet.draw not working #41

Open nyrull opened 7 years ago

nyrull commented 7 years ago

Hi, Im having trouble to enable snapping when im in edit mode. If i draw a polygon and then another one it snap no problem. Then i hit the edit button and i can edit the two shape no problem except there is no snapping during this process. After edition if i draw another polygon it snap to the other two as expected. So my only problem is during edition,there is no snapping,how can i enable it ? I use Draw 3.0,leaflet 0.7.5 . The snap.js and geometryutil.js are from the exemple. Here is my code :


 $(document).ready(function () {
        var guideLayers = [];

         var   map = L.map('mapContainer', {
                layers: MQ.mapLayer(),
                center: [46.814184, -71.207425],
                zoomControl: true,
                zoom: 8
            });

         var   drawnItems = new L.FeatureGroup();
            map.addLayer(drawnItems);

          var   drawControl = new L.Control.Draw({
                draw: {
                    circle: false,
                    marker: false,
                    polyline: false,
                    rectangle:false,
                    polygon: {
                        guideLayers: guideLayers, 
                        snapDistance: 5,
                        allowIntersection: false,
                        showArea: true,
                        drawError: {
                            color: '#b00b00',
                            timeout: 1000
                        },
                    }
                },
                edit: {
                    featureGroup: drawnItems,
                    edit: true,
                    remove:false
                }
            });
             map.addControl(drawControl);

             map.on('draw:created', function (e) {
                 var type = e.layerType,
                     layer = e.layer;         
                 drawnItems.addLayer(layer);                                              
                 guideLayers.push(layer);
             });           

        });

I tried with L.EditToolbar.SnapEdit and didnt get snapping while editing. If someone can help me i would appreciate it thx.

nyrull commented 7 years ago

Hi, any news on a possible fix ?

v1r0x commented 7 years ago

Having the same problem. But I'm on leaflet 1.0.3, Leaflet.Draw 0.4.9.

peterlawless commented 7 years ago

+1