diff --git a/cypress/integration/rectangle.spec.js b/cypress/integration/rectangle.spec.js index e007c5a6..c67a0430 100644 --- a/cypress/integration/rectangle.spec.js +++ b/cypress/integration/rectangle.spec.js @@ -190,6 +190,35 @@ describe('Draw Rectangle', () => { }); }); + it('disable popup on pmIgnore-layer while drawing', () => { + let rect = null; + cy.window().then(({ map, L }) => { + map.on('pm:create', (e) => { + e.layer.bindPopup('Popup test'); + if (e.layer instanceof L.Rectangle) { + e.layer.options.pmIgnore = true; + rect = e.layer; + } + }); + }); + + cy.toolbarButton('rectangle').click(); + cy.get(mapSelector).click(100, 50).click(700, 400); + + cy.toolbarButton('marker').click(); + cy.get(mapSelector).click(300, 250); + + cy.toolbarButton('edit').click(); + + cy.window().then(({ map }) => { + const len = map.pm.getGeomanDrawLayers().length; + expect(len).to.equal(1); + + const text = rect.getPopup().getContent(); + expect(text).to.equal('Popup test'); + }); + }); + it('prevent not correct created snaplist', () => { cy.window().then(({ map }) => { map.on('pm:create', (e) => { diff --git a/src/js/Draw/L.PM.Draw.js b/src/js/Draw/L.PM.Draw.js index d8052352..1efa1928 100644 --- a/src/js/Draw/L.PM.Draw.js +++ b/src/js/Draw/L.PM.Draw.js @@ -136,7 +136,22 @@ const Draw = L.Class.extend({ this._fireGlobalDrawModeToggled(); } - const layers = L.PM.Utils.findLayers(this._map); + const layers = []; + this._map.eachLayer((layer) => { + if ( + layer instanceof L.Polyline || + layer instanceof L.Marker || + layer instanceof L.Circle || + layer instanceof L.CircleMarker || + layer instanceof L.ImageOverlay + ) { + // filter out everything that's leaflet-geoman specific temporary stuff + if (!layer._pmTempLayer) { + layers.push(layer); + } + } + }); + if (this._enabled) { layers.forEach((layer) => { L.PM.Utils.disablePopup(layer);