Make layer renderers more stupid

Layer renderers should not be responsible for listening to layer
properties change and triggering a render.
Layer change events are now forwarded to the map which will trigger a render.
This commit is contained in:
Bruno Binet
2013-08-07 15:55:54 +02:00
parent a13d4bdded
commit 46ea218d0f
4 changed files with 34 additions and 140 deletions
+5 -21
View File
@@ -92,11 +92,11 @@ ol.layer.LayerGroup.prototype.handleLayersChanged_ = function(event) {
layer = layersArray[i];
this.listenerKeys_[goog.getUid(layer).toString()] =
goog.events.listen(layer, goog.events.EventType.CHANGE,
this.handleLayerChange_, false, this);
this.handleLayerChange, false, this);
}
}
this.dispatchChangeEvent_();
this.dispatchChangeEvent();
};
@@ -107,9 +107,9 @@ ol.layer.LayerGroup.prototype.handleLayersChanged_ = function(event) {
ol.layer.LayerGroup.prototype.handleLayersAdd_ = function(collectionEvent) {
var layer = /** @type {ol.layer.LayerBase} */ (collectionEvent.elem);
this.listenerKeys_[goog.getUid(layer).toString()] = goog.events.listen(
layer, goog.events.EventType.CHANGE, this.handleLayerChange_, false,
layer, goog.events.EventType.CHANGE, this.handleLayerChange, false,
this);
this.dispatchChangeEvent_();
this.dispatchChangeEvent();
};
@@ -122,23 +122,7 @@ ol.layer.LayerGroup.prototype.handleLayersRemove_ = function(collectionEvent) {
var key = goog.getUid(layer).toString();
goog.events.unlistenByKey(this.listenerKeys_[key]);
delete this.listenerKeys_[key];
this.dispatchChangeEvent_();
};
/**
* @private
*/
ol.layer.LayerGroup.prototype.handleLayerChange_ = function() {
this.dispatchChangeEvent_();
};
/**
* @private
*/
ol.layer.LayerGroup.prototype.dispatchChangeEvent_ = function() {
this.dispatchEvent(goog.events.EventType.CHANGE);
this.dispatchChangeEvent();
};