Merge pull request #10259 from fredj/abortDrawing
Remove all the sketch features in abortDrawing
This commit is contained in:
@@ -881,12 +881,10 @@ class Draw extends PointerInteraction {
|
||||
abortDrawing_() {
|
||||
this.finishCoordinate_ = null;
|
||||
const sketchFeature = this.sketchFeature_;
|
||||
if (sketchFeature) {
|
||||
this.sketchFeature_ = null;
|
||||
this.sketchPoint_ = null;
|
||||
this.sketchLine_ = null;
|
||||
this.overlay_.getSource().clear(true);
|
||||
}
|
||||
this.sketchFeature_ = null;
|
||||
this.sketchPoint_ = null;
|
||||
this.sketchLine_ = null;
|
||||
this.overlay_.getSource().clear(true);
|
||||
return sketchFeature;
|
||||
}
|
||||
|
||||
|
||||
@@ -1080,6 +1080,24 @@ describe('ol.interaction.Draw', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setMap(null) when no drawing is in progress', function() {
|
||||
beforeEach(function() {
|
||||
map.addInteraction(interaction);
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
expect(interaction.sketchFeature_).to.be(null);
|
||||
expect(interaction.sketchPoint_).not.to.be(null);
|
||||
});
|
||||
afterEach(function() {
|
||||
map.removeInteraction(interaction);
|
||||
});
|
||||
it('clears the sketch features', function() {
|
||||
interaction.setMap(null);
|
||||
expect(interaction.sketchFeature_).to.be(null);
|
||||
expect(interaction.sketchPoint_).to.be(null);
|
||||
expect(interaction.sketchLine_).to.be(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setMap(map)', function() {
|
||||
describe('#setMap(map) when interaction is active', function() {
|
||||
it('sets the map into the feature overlay', function() {
|
||||
|
||||
Reference in New Issue
Block a user