Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snapping while editing with leaflet.draw not working #41

Open
nyrull opened this issue Dec 13, 2016 · 3 comments
Open

Snapping while editing with leaflet.draw not working #41

nyrull opened this issue Dec 13, 2016 · 3 comments

Comments

@nyrull
Copy link

nyrull commented Dec 13, 2016

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
Copy link
Author

nyrull commented Feb 9, 2017

Hi, any news on a possible fix ?

@v1r0x
Copy link

v1r0x commented May 12, 2017

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

@peterlawless
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants