From cd08fb5b5be7544aaf70e87d843fad8741e4af93 Mon Sep 17 00:00:00 2001 From: Florian Bischof Date: Sun, 29 Dec 2024 14:04:03 +0100 Subject: [PATCH 1/2] Fix: Circle outer-marker snapping didn't change radius --- cypress/e2e/circle.cy.js | 23 +++++++++++++++++++++++ src/js/Edit/L.PM.Edit.CircleMarker.js | 4 ++++ src/js/Toolbar/L.Controls.js | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/circle.cy.js b/cypress/e2e/circle.cy.js index d2be9b1b..fd340d08 100644 --- a/cypress/e2e/circle.cy.js +++ b/cypress/e2e/circle.cy.js @@ -526,4 +526,27 @@ describe('Draw Circle', () => { expect(layer.getRadius()).to.eq(1328.278061564339); }); }); + + it('checks if radius is changed when outer marker is snapped', () => { + cy.toolbarButton('rectangle').click(); + cy.get(mapSelector).click(100, 100).click(400, 350); + + cy.toolbarButton('circle').click(); + cy.get(mapSelector).click(300, 200).click(400, 200); + + cy.toolbarButton('edit').click(); + + // move marker + cy.get(mapSelector) + .trigger('mousedown', 400, 200, { which: 1 }) + .trigger('mousemove', 390, 230, { which: 1 }) + .trigger('mouseup', 390, 230, { which: 1 }); + + cy.window().then(({ map }) => { + const layer = map.pm.getGeomanLayers()[1]; + expect(layer.getLatLng().lat).to.eq(51.51034504891232); + expect(layer.getLatLng().lng).to.eq(-0.12428283691406251); + expect(layer.getRadius()).to.eq(1240.3294565841613); + }); + }); }); diff --git a/src/js/Edit/L.PM.Edit.CircleMarker.js b/src/js/Edit/L.PM.Edit.CircleMarker.js index fdb323bf..090f597a 100644 --- a/src/js/Edit/L.PM.Edit.CircleMarker.js +++ b/src/js/Edit/L.PM.Edit.CircleMarker.js @@ -128,6 +128,10 @@ Edit.CircleMarker = Edit.extend({ this._initSnappableMarkers(); // update marker latlng when snapped latlng radius is out of min/max this._outerMarker.on('drag', this._handleOuterMarkerSnapping, this); + // sync the hintline with hint marker + this._outerMarker.on('move', this._syncHintLine, this); + this._outerMarker.on('move', this._syncCircleRadius, this); + this._centerMarker.on('move', this._moveCircle, this); } else { this._disableSnapping(); } diff --git a/src/js/Toolbar/L.Controls.js b/src/js/Toolbar/L.Controls.js index e0d9a15b..da190522 100644 --- a/src/js/Toolbar/L.Controls.js +++ b/src/js/Toolbar/L.Controls.js @@ -169,7 +169,7 @@ const PMButton = L.Control.extend({ } else if (_action.text) { action = _action; } else { - return; + return action; } const actionNode = L.DomUtil.create( 'a', From 7d6c905b7c53457394d5780d4d2662c1b3baf1ce Mon Sep 17 00:00:00 2001 From: Florian Bischof Date: Sun, 29 Dec 2024 14:06:32 +0100 Subject: [PATCH 2/2] Remove obsolete line --- src/js/Edit/L.PM.Edit.CircleMarker.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/js/Edit/L.PM.Edit.CircleMarker.js b/src/js/Edit/L.PM.Edit.CircleMarker.js index 090f597a..9c17a251 100644 --- a/src/js/Edit/L.PM.Edit.CircleMarker.js +++ b/src/js/Edit/L.PM.Edit.CircleMarker.js @@ -131,7 +131,6 @@ Edit.CircleMarker = Edit.extend({ // sync the hintline with hint marker this._outerMarker.on('move', this._syncHintLine, this); this._outerMarker.on('move', this._syncCircleRadius, this); - this._centerMarker.on('move', this._moveCircle, this); } else { this._disableSnapping(); }