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`.
This commit is contained in:
Frederic Junod
2016-02-03 15:21:41 +01:00
parent 57c5632de2
commit a44e71aad1
+12 -8
View File
@@ -330,15 +330,19 @@ ol.interaction.Snap.prototype.setMap = function(map) {
if (map) { if (map) {
if (this.features_) { if (this.features_) {
keys.push(this.features_.on(ol.CollectionEventType.ADD, keys.push(
this.handleFeatureAdd_, this)); ol.events.listen(this.features_, ol.CollectionEventType.ADD,
keys.push(this.features_.on(ol.CollectionEventType.REMOVE, this.handleFeatureAdd_, this),
this.handleFeatureRemove_, this)); ol.events.listen(this.features_, ol.CollectionEventType.REMOVE,
this.handleFeatureRemove_, this)
);
} else if (this.source_) { } else if (this.source_) {
keys.push(this.source_.on(ol.source.VectorEventType.ADDFEATURE, keys.push(
this.handleFeatureAdd_, this)); ol.events.listen(this.source_, ol.source.VectorEventType.ADDFEATURE,
keys.push(this.source_.on(ol.source.VectorEventType.REMOVEFEATURE, this.handleFeatureAdd_, this),
this.handleFeatureRemove_, this)); ol.events.listen(this.source_, ol.source.VectorEventType.REMOVEFEATURE,
this.handleFeatureRemove_, this)
);
} }
features.forEach(this.forEachFeatureAdd_, this); features.forEach(this.forEachFeatureAdd_, this);
} }