Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.0 #406

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ See the available options in the table below.
| snapDistance | `20` | the distance to another vertex when a snap should happen |
| snapMiddle | `false` | allow snapping to the middle of a layers segments (between two vertexes) |
| tooltips | `true` | show helpful tooltips for your user |
| allowSelfIntersection | `true` | allow self intersections |
| allowSelfIntersection | `false` | allow self intersections |
| templineStyle | `{ color: 'red' },` | [leaflet path options](https://leafletjs.com/reference-1.4.0.html#path) for the lines between drawn vertices/markers. |
| hintlineStyle | `{ color: 'red', dashArray: [5, 5] }` | [leaflet path options](https://leafletjs.com/reference-1.4.0.html#path) for the helper line between last drawn vertex and the cursor. |
| cursorMarker | `true` | show a marker at the cursor |
Expand Down Expand Up @@ -224,7 +224,7 @@ Let's you edit vertices of layers. Use it like this:
```js
// enable edit mode
layer.pm.enable({
allowSelfIntersection: false,
allowSelfIntersection: true,
});
```

Expand All @@ -234,7 +234,7 @@ See the available options in the table below.
| :-------------------- | :------ | :-------------------------------------------------------------------------------------------------------- |
| snappable | `true` | Enable snapping to other layers vertices for precision drawing. Can be disabled by holding the `ALT` key. |
| snapDistance | `20` | The distance to another vertex when a snap should happen. |
| allowSelfIntersection | `true` | Allow/Disallow self-intersections on polygons and polylines. |
| allowSelfIntersection | `false` | Allow/Disallow self-intersections on polygons and polylines. |
| preventMarkerRemoval | `false` | Disable the removal of markers/vertexes via right click. |

The following methods are available for layers under `layer.pm`:
Expand Down
22 changes: 14 additions & 8 deletions cypress/integration/polygon.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,11 @@ describe('Draw & Edit Poly', () => {

it('prevents self intersections', () => {
cy.window().then(({ map }) => {
map.pm.enableDraw('Polygon', {
allowSelfIntersection: false,
});
map.pm.enableDraw('Polygon');

Cypress.$(map).on('pm:create', ({ originalEvent: event }) => {
const poly = event.layer;
poly.pm.enable({
allowSelfIntersection: false,
});
poly.pm.enable();
});
});

Expand Down Expand Up @@ -219,8 +215,14 @@ describe('Draw & Edit Poly', () => {
cy.hasLayers(1);

// activate polygon drawing
cy.window().then(({ map }) => {
map.pm.enableDraw('Polygon', {
allowSelfIntersection: true,
});
});

// check button activity
cy.toolbarButton('polygon')
.click()
.closest('.button-container')
.should('have.class', 'active');

Expand All @@ -241,7 +243,11 @@ describe('Draw & Edit Poly', () => {
cy.hasLayers(3);

// enable global edit mode
cy.toolbarButton('edit').click();
cy.window().then(({ map }) => {
map.pm.enableGlobalEditMode({
allowSelfIntersection: true,
});
});

cy.hasVertexMarkers(5);
cy.hasMiddleMarkers(5);
Expand Down
2 changes: 1 addition & 1 deletion src/js/Draw/L.PM.Draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Draw = L.Class.extend({
cursorMarker: true,
finishOnDoubleClick: false,
finishOn: null,
allowSelfIntersection: true,
allowSelfIntersection: false,
templineStyle: {},
hintlineStyle: {
color: '#3388ff',
Expand Down
2 changes: 1 addition & 1 deletion src/js/Edit/L.PM.Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Edit = L.Class.extend({
options: {
snappable: true,
snapDistance: 20,
allowSelfIntersection: true,
allowSelfIntersection: false,
draggable: true,
},
isPolygon() {
Expand Down
1 change: 0 additions & 1 deletion src/js/Toolbar/L.PM.Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ const Toolbar = L.Class.extend({
this.map.pm.Draw.Cut.toggle({
snappable: true,
cursorMarker: true,
allowSelfIntersection: false,
});
},
doToggle: true,
Expand Down