From 787f2ba97968a1e0db04954b707b41572d31d1ef Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 22 Jun 2012 20:37:29 +0200 Subject: [PATCH] Common method for conditionally rendering. --- src/ol/Map.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ol/Map.js b/src/ol/Map.js index 6252cd2eed..b21f1a50c7 100644 --- a/src/ol/Map.js +++ b/src/ol/Map.js @@ -293,7 +293,10 @@ ol.Map.prototype.setUserProjection = function(userProjection) { * @param {number} zoom Zoom. */ ol.Map.prototype.setZoom = function(zoom) { - this.zoom_ = zoom; + if (zoom !== this.zoom_) { + this.zoom_ = zoom; + this.conditionallyRender(); + } }; @@ -360,6 +363,13 @@ ol.Map.prototype.setContainer = function(container) { // controls place on overlays. this.setControls(ol.Map.DEFAULT_CONTROLS); // conditionally render + this.conditionallyRender(); +}; + +/** + * Check if everything is ready. Render if so. + */ +ol.Map.prototype.conditionallyRender = function() { if (!goog.isNull(this.layers_) && goog.isDef(this.zoom_) && !goog.isNull(this.center_)) { this.renderer_.draw(this.layers_, this.center_, this.getResolutionForZoom(this.zoom_)); }