leanna
leanna

Reputation: 11

Leaflet Snap - Cannot snap when drawing using Leaflet Draw

I'm quite new in js and leaflet and I need your help. I use leaflet draw for drawing and editing polygons on a map and I need to be able to snap to other polygons while drawing. I used plugin Leaflet Snap for this and it works - unfortunately only when the polygon is already in map so it only works for editing. I can't seem to find solution for this anywhere on the internet. It is working in this demo - http://makinacorpus.github.io/Leaflet.Snap/. BUT - it only works when you initialize drawControl like this var map = L.map('map', {drawControl: true})

The problem is, I need to create toolbar with L.Control.Draw because I only need to draw polygon and marker and not all the other stuff:

let drawControlFull = new L.Control.Draw({
                    edit: {
                        featureGroup: this.newLayer
                    },
                    draw: {
                        polyline: false,
                        circle: false,
                        rectangle: false,
                        circlemarker: false,
                        polygon: {
                            guideLayers: [this.floorPolygons],
                        }
                    }
                });

Since I'm building large Vue app I can only provide easy example https://jsfiddle.net/leanna_b/kwp2uh7a/. Any ideas where the problem might be? Thank you so much for any help!

Upvotes: 1

Views: 544

Answers (0)

Related Questions