Skip to content

Commit 2cb1ff7

Browse files
authored
Merge pull request #1549 from Falke-Design/fix/circle_marker_snapping
Fix: Circle outer-marker snapping didn't change radius
2 parents 025f768 + 7d6c905 commit 2cb1ff7

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

cypress/e2e/circle.cy.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,4 +526,27 @@ describe('Draw Circle', () => {
526526
expect(layer.getRadius()).to.eq(1328.278061564339);
527527
});
528528
});
529+
530+
it('checks if radius is changed when outer marker is snapped', () => {
531+
cy.toolbarButton('rectangle').click();
532+
cy.get(mapSelector).click(100, 100).click(400, 350);
533+
534+
cy.toolbarButton('circle').click();
535+
cy.get(mapSelector).click(300, 200).click(400, 200);
536+
537+
cy.toolbarButton('edit').click();
538+
539+
// move marker
540+
cy.get(mapSelector)
541+
.trigger('mousedown', 400, 200, { which: 1 })
542+
.trigger('mousemove', 390, 230, { which: 1 })
543+
.trigger('mouseup', 390, 230, { which: 1 });
544+
545+
cy.window().then(({ map }) => {
546+
const layer = map.pm.getGeomanLayers()[1];
547+
expect(layer.getLatLng().lat).to.eq(51.51034504891232);
548+
expect(layer.getLatLng().lng).to.eq(-0.12428283691406251);
549+
expect(layer.getRadius()).to.eq(1240.3294565841613);
550+
});
551+
});
529552
});

src/js/Edit/L.PM.Edit.CircleMarker.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ Edit.CircleMarker = Edit.extend({
128128
this._initSnappableMarkers();
129129
// update marker latlng when snapped latlng radius is out of min/max
130130
this._outerMarker.on('drag', this._handleOuterMarkerSnapping, this);
131+
// sync the hintline with hint marker
132+
this._outerMarker.on('move', this._syncHintLine, this);
133+
this._outerMarker.on('move', this._syncCircleRadius, this);
131134
} else {
132135
this._disableSnapping();
133136
}

src/js/Toolbar/L.Controls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ const PMButton = L.Control.extend({
169169
} else if (_action.text) {
170170
action = _action;
171171
} else {
172-
return;
172+
return action;
173173
}
174174
const actionNode = L.DomUtil.create(
175175
'a',

0 commit comments

Comments
 (0)