Render map when layer.setMap(map) called

This commit is contained in:
Éric Lemoine
2015-08-19 14:16:48 +02:00
parent 33da0e7b66
commit b1973fcdf4
2 changed files with 52 additions and 22 deletions

View File

@@ -161,8 +161,12 @@ ol.layer.Layer.prototype.handleSourcePropertyChange_ = function() {
*/
ol.layer.Layer.prototype.setMap = function(map) {
goog.events.unlistenByKey(this.mapPrecomposeKey_);
this.changed();
this.mapPrecomposeKey_ = null;
if (goog.isNull(map)) {
this.changed();
}
goog.events.unlistenByKey(this.mapRenderKey_);
this.mapRenderKey_ = null;
if (!goog.isNull(map)) {
this.mapPrecomposeKey_ = goog.events.listen(
map, ol.render.EventType.PRECOMPOSE, function(evt) {
@@ -173,6 +177,7 @@ ol.layer.Layer.prototype.setMap = function(map) {
}, false, this);
this.mapRenderKey_ = goog.events.listen(
this, goog.events.EventType.CHANGE, map.render, false, map);
this.changed();
}
};