Simpler type for ol.events.Key
Instead of having `ol.events.Key` be a listener object or an array of listener objects, it should be less error prone to have it just be a single listener object. To avoid using too many functions with multiple return types, the `ol.events.*` functions for registering and unregistering listeners no longer accept an array of event types (and only a single key is returned when registering). To make it convenient for users to register multiple listeners at once, the `observable.on()` method accepts an array of event types. Internally in the library, we should use the less risky `ol.events.listen()`.
This commit is contained in:
committed by
Andreas Hocevar
parent
78f44dcc8a
commit
f10c90bdba
@@ -153,8 +153,11 @@ ol.interaction.DragAndDrop.prototype.setMap = function(map) {
|
||||
this.dropListenKeys_ = [
|
||||
ol.events.listen(dropArea, ol.events.EventType.DROP,
|
||||
ol.interaction.DragAndDrop.handleDrop_, this),
|
||||
ol.events.listen(dropArea, [ol.events.EventType.DRAGENTER,
|
||||
ol.events.EventType.DRAGOVER, ol.events.EventType.DROP],
|
||||
ol.events.listen(dropArea, ol.events.EventType.DRAGENTER,
|
||||
ol.interaction.DragAndDrop.handleStop_, this),
|
||||
ol.events.listen(dropArea, ol.events.EventType.DRAGOVER,
|
||||
ol.interaction.DragAndDrop.handleStop_, this),
|
||||
ol.events.listen(dropArea, ol.events.EventType.DROP,
|
||||
ol.interaction.DragAndDrop.handleStop_, this)
|
||||
]
|
||||
}
|
||||
|
||||
@@ -168,11 +168,13 @@ ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) {
|
||||
segmentWriter.call(this, feature, geometry);
|
||||
|
||||
if (listen) {
|
||||
this.geometryModifyListenerKeys_[feature_uid] = geometry.on(
|
||||
this.geometryModifyListenerKeys_[feature_uid] = ol.events.listen(
|
||||
geometry,
|
||||
ol.events.EventType.CHANGE,
|
||||
this.handleGeometryModify_.bind(this, feature),
|
||||
this);
|
||||
this.geometryChangeListenerKeys_[feature_uid] = feature.on(
|
||||
this.geometryChangeListenerKeys_[feature_uid] = ol.events.listen(
|
||||
feature,
|
||||
ol.Object.getChangeEventType(feature.getGeometryName()),
|
||||
this.handleGeometryChange_, this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user