diff --git a/src/ol/interaction/modify.js b/src/ol/interaction/modify.js index d95c5eb49e..755c16af9c 100644 --- a/src/ol/interaction/modify.js +++ b/src/ol/interaction/modify.js @@ -258,6 +258,18 @@ ol.interaction.Modify.prototype.removeFeatureSegmentData_ = function(feature) { }; +/** + * @inheritDoc + */ +ol.interaction.Modify.prototype.setActive = function(active) { + if (this.vertexFeature_ && !active) { + this.overlay_.getSource().removeFeature(this.vertexFeature_); + this.vertexFeature_ = null; + } + ol.interaction.Pointer.prototype.setActive.call(this, active); +}; + + /** * @inheritDoc */ diff --git a/test/spec/ol/interaction/modify.test.js b/test/spec/ol/interaction/modify.test.js index 66b91f7209..cb3843a84a 100644 --- a/test/spec/ol/interaction/modify.test.js +++ b/test/spec/ol/interaction/modify.test.js @@ -534,4 +534,20 @@ describe('ol.interaction.Modify', function() { }); }); + describe('#setActive', function() { + it('removes the vertexFeature of deactivation', function() { + var modify = new ol.interaction.Modify({ + features: new ol.Collection(features) + }); + map.addInteraction(modify); + expect(modify.vertexFeature_).to.be(null); + + simulateEvent('pointermove', 10, -20, false, 0); + expect(modify.vertexFeature_).to.not.be(null); + + modify.setActive(false); + expect(modify.vertexFeature_).to.be(null); + }); + }); + });