Skip to content

Commit

Permalink
Fixed a bug where circles within featureGroups can't be edited multip…
Browse files Browse the repository at this point in the history
…le times
  • Loading branch information
codeofsumit committed Oct 31, 2018
1 parent ad70532 commit 4f47e78
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
29 changes: 28 additions & 1 deletion cypress/integration/layergroup.spec.js
@@ -1,10 +1,37 @@
describe('Edit LayerGroup', () => {
const mapSelector = '#map';
// const mapSelector = '#map';

it('correctly enables geojson featureCollection', () => {
cy.drawShape('FeatureCollectionWithCircles');

cy.toolbarButton('edit').click();
cy.hasVertexMarkers(21);
cy.toolbarButton('edit').click();
cy.hasVertexMarkers(0);
});

it('enables all layers of layerGroup', () => {
cy.drawShape('FeatureCollectionWithCircles');

cy.get('@featurecol').then(feature => {
feature.pm.enable();
});

cy.hasVertexMarkers(21);

cy.get('@featurecol').then(feature => {
feature.pm.disable();
});
cy.hasVertexMarkers(0);

cy.get('@featurecol').then(feature => {
feature.pm.toggleEdit();
});
cy.hasVertexMarkers(21);

cy.get('@featurecol').then(feature => {
feature.pm.toggleEdit();
});
cy.hasVertexMarkers(0);
});
});
6 changes: 4 additions & 2 deletions cypress/support/commands.js
Expand Up @@ -59,7 +59,6 @@ Cypress.Commands.add('drawShape', (shape) => {

if (shape === 'FeatureCollectionWithCircles') {
cy.fixture(shape)
.as('poly')
.then((json) => {
const layer = L.geoJson(json, {
pointToLayer: (feature, latlng) => {
Expand All @@ -77,7 +76,10 @@ Cypress.Commands.add('drawShape', (shape) => {

const bounds = layer.getBounds();
map.fitBounds(bounds);
});

return layer;
})
.as('featurecol');
}
});
});
2 changes: 1 addition & 1 deletion src/js/Edit/L.PM.Edit.Circle.js
Expand Up @@ -48,7 +48,7 @@ Edit.Circle = Edit.extend({
return false;
}
layer.pm._enabled = false;
layer.pm._layerGroup.clearLayers();
layer.pm._helperLayers.clearLayers();

// clean up draggable
layer.off('mousedown');
Expand Down
7 changes: 2 additions & 5 deletions src/js/Edit/L.PM.Edit.LayerGroup.js
Expand Up @@ -82,16 +82,13 @@ Edit.LayerGroup = L.Class.extend({
toggleEdit(options) {
this._options = options;
this._layers.forEach((layer) => {
console.log('TOGGLE EDIT');
// layer.pm.toggleEdit(options);
layer.pm.toggleEdit(options);
});
},
enable(options) {
console.log('ENABLE');
this._options = options;
this._layers.forEach((layer) => {
console.log(layer);
// layer.pm.enable(options);
layer.pm.enable(options);
});
},
disable() {
Expand Down

0 comments on commit 4f47e78

Please sign in to comment.