Skip to content

Commit

Permalink
Fix snapping of circle center marker (geoman-io#1036)
Browse files Browse the repository at this point in the history
* Fix snapping of circle center marker geoman-io#983

* Bump path-parse from 1.0.6 to 1.0.7 (geoman-io#1020)

Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and BaharWeb committed May 13, 2022
1 parent e44149b commit 67b191e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
23 changes: 23 additions & 0 deletions cypress/integration/circle.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,27 @@ describe('Draw Circle', () => {
});
cy.hasLayers(3);
});
it('check if snapping works with max radius of circle', () => {
cy.toolbarButton('circle')
.click()
.closest('.button-container')
.should('have.class', 'active');

cy.get(mapSelector).click(350, 250).click(450, 250);

cy.window().then(({ map }) => {
map.pm.setGlobalOptions({
maxRadiusCircle: 1500,
});
});

cy.toolbarButton('circle').click();
cy.get(mapSelector).click(355, 250).click(475, 250);

cy.window().then(({ map }) => {
const layer = map.pm.getGeomanDrawLayers()[0];
const layer2 = map.pm.getGeomanDrawLayers()[1];
expect(layer.getLatLng().equals(layer2.getLatLng())).to.eq(true);
});
});
});
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/js/Draw/L.PM.Draw.Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ Draw.Circle = Draw.extend({
const latlng = this._centerMarker.getLatLng();
const secondLatLng = this._hintMarker.getLatLng();
const distance = latlng.distanceTo(secondLatLng);
if (
if (latlng.equals(L.latLng([0, 0]))) {
// do nothing
} else if (
this.options.minRadiusCircle &&
distance < this.options.minRadiusCircle
) {
Expand Down

0 comments on commit 67b191e

Please sign in to comment.