Update finishCoordinate in ol.interaction.Draw#removeLastPoint

And don't crash if the function is called but no feature is drawn
This commit is contained in:
Frederic Junod
2017-04-10 12:34:44 +02:00
parent aaf3256279
commit d97d5e5164
2 changed files with 56 additions and 0 deletions

View File

@@ -289,6 +289,31 @@ describe('ol.interaction.Draw', function() {
expect(geometry.getCoordinates()).to.eql([[10, -20], [30, -20]]);
});
it('supports removeLastPoint while drawing', function() {
draw.removeLastPoint();
// first point
simulateEvent('pointermove', 10, 20);
simulateEvent('pointerdown', 10, 20);
simulateEvent('pointerup', 10, 20);
// second point
simulateEvent('pointermove', 40, 30);
simulateEvent('pointerdown', 40, 30);
simulateEvent('pointerup', 40, 30);
simulateEvent('pointermove', 100, 100);
draw.removeLastPoint();
// click near the removed point
simulateEvent('pointermove', 39, 31);
simulateEvent('pointerdown', 38, 31);
simulateEvent('pointerup', 38, 31);
expect(source.getFeatures()).to.have.length(0);
});
it('supports freehand drawing for linestrings', function() {
// freehand sequence
simulateEvent('pointermove', 10, 20);
@@ -534,6 +559,31 @@ describe('ol.interaction.Draw', function() {
]);
});
it('supports removeLastPoint while drawing', function() {
draw.removeLastPoint();
// first point
simulateEvent('pointermove', 10, 20);
simulateEvent('pointerdown', 10, 20);
simulateEvent('pointerup', 10, 20);
// second point
simulateEvent('pointermove', 40, 30);
simulateEvent('pointerdown', 40, 30);
simulateEvent('pointerup', 40, 30);
simulateEvent('pointermove', 100, 100);
draw.removeLastPoint();
// click near the removed point
simulateEvent('pointermove', 39, 31);
simulateEvent('pointerdown', 39, 31);
simulateEvent('pointerup', 39, 31);
expect(source.getFeatures()).to.have.length(0);
});
it('draws polygon with clicks, finishing on last point', function() {
// first point
simulateEvent('pointermove', 10, 20);