Remove the vertex on ol.interaction.Modify deactivation
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user