Merge pull request #4023 from elemoine/4003

Render map when layer.setMap(map) called
This commit is contained in:
Éric Lemoine
2015-08-20 15:31:07 +02:00
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();
}
};