Merge pull request #929 from elemoine/collectionevent
Add ol.CollectionEvent#getElement
This commit is contained in:
@@ -10,3 +10,5 @@
|
||||
@exportProperty ol.Collection.prototype.remove
|
||||
@exportProperty ol.Collection.prototype.removeAt
|
||||
@exportProperty ol.Collection.prototype.setAt
|
||||
|
||||
@exportProperty ol.CollectionEvent.prototype.getElement
|
||||
|
||||
@@ -35,14 +35,23 @@ ol.CollectionEvent = function(type, opt_elem, opt_target) {
|
||||
goog.base(this, type, opt_target);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {*}
|
||||
*/
|
||||
this.elem = opt_elem;
|
||||
this.elem_ = opt_elem;
|
||||
|
||||
};
|
||||
goog.inherits(ol.CollectionEvent, goog.events.Event);
|
||||
|
||||
|
||||
/**
|
||||
* @return {*} The element to which this event pertains.
|
||||
*/
|
||||
ol.CollectionEvent.prototype.getElement = function() {
|
||||
return this.elem_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
|
||||
@@ -123,7 +123,7 @@ ol.layer.LayerGroup.prototype.handleLayersChanged_ = function(event) {
|
||||
* @private
|
||||
*/
|
||||
ol.layer.LayerGroup.prototype.handleLayersAdd_ = function(collectionEvent) {
|
||||
var layer = /** @type {ol.layer.LayerBase} */ (collectionEvent.elem);
|
||||
var layer = /** @type {ol.layer.LayerBase} */ (collectionEvent.getElement());
|
||||
this.listenerKeys_[goog.getUid(layer).toString()] = goog.events.listen(
|
||||
layer, goog.events.EventType.CHANGE, this.handleLayerChange, false,
|
||||
this);
|
||||
@@ -136,7 +136,7 @@ ol.layer.LayerGroup.prototype.handleLayersAdd_ = function(collectionEvent) {
|
||||
* @private
|
||||
*/
|
||||
ol.layer.LayerGroup.prototype.handleLayersRemove_ = function(collectionEvent) {
|
||||
var layer = /** @type {ol.layer.LayerBase} */ (collectionEvent.elem);
|
||||
var layer = /** @type {ol.layer.LayerBase} */ (collectionEvent.getElement());
|
||||
var key = goog.getUid(layer).toString();
|
||||
goog.events.unlistenByKey(this.listenerKeys_[key]);
|
||||
delete this.listenerKeys_[key];
|
||||
|
||||
Reference in New Issue
Block a user