From a44e71aad1d3b2d6e6822f709f365eeac47e8ed7 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 3 Feb 2016 15:21:41 +0100 Subject: [PATCH] Use ol.events.listen instead of ol.Observable#on `ol.Observable#on` may return an array of `ol.events.Key`, `ol.events.listen` always return a single `ol.events.Key`. --- src/ol/interaction/snapinteraction.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ol/interaction/snapinteraction.js b/src/ol/interaction/snapinteraction.js index ceb92583b1..b952c684a6 100644 --- a/src/ol/interaction/snapinteraction.js +++ b/src/ol/interaction/snapinteraction.js @@ -330,15 +330,19 @@ ol.interaction.Snap.prototype.setMap = function(map) { if (map) { if (this.features_) { - keys.push(this.features_.on(ol.CollectionEventType.ADD, - this.handleFeatureAdd_, this)); - keys.push(this.features_.on(ol.CollectionEventType.REMOVE, - this.handleFeatureRemove_, this)); + keys.push( + ol.events.listen(this.features_, ol.CollectionEventType.ADD, + this.handleFeatureAdd_, this), + ol.events.listen(this.features_, ol.CollectionEventType.REMOVE, + this.handleFeatureRemove_, this) + ); } else if (this.source_) { - keys.push(this.source_.on(ol.source.VectorEventType.ADDFEATURE, - this.handleFeatureAdd_, this)); - keys.push(this.source_.on(ol.source.VectorEventType.REMOVEFEATURE, - this.handleFeatureRemove_, this)); + keys.push( + ol.events.listen(this.source_, ol.source.VectorEventType.ADDFEATURE, + this.handleFeatureAdd_, this), + ol.events.listen(this.source_, ol.source.VectorEventType.REMOVEFEATURE, + this.handleFeatureRemove_, this) + ); } features.forEach(this.forEachFeatureAdd_, this); }