From b499f71d974814f7409ac4f62cb28b7e4bb34aea Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 10 Apr 2013 12:47:06 -0600 Subject: [PATCH] Add an updateSize method We need a non-private/protected method to call when the map viewport size changes. --- src/ol/map.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/ol/map.js b/src/ol/map.js index c6026a7e7f..335cb64873 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -261,7 +261,7 @@ ol.Map = function(options) { this.viewportSizeMonitor_ = new goog.dom.ViewportSizeMonitor(); goog.events.listen(this.viewportSizeMonitor_, goog.events.EventType.RESIZE, - this.handleBrowserWindowResize, false, this); + this.updateSize, false, this); /** * @private @@ -305,7 +305,7 @@ ol.Map = function(options) { this.setValues(optionsInternal.values); // this gives the map an initial size - this.handleBrowserWindowResize(); + this.updateSize(); if (goog.isDef(optionsInternal.controls)) { goog.array.forEach(optionsInternal.controls, @@ -619,15 +619,6 @@ ol.Map.prototype.handleBackgroundColorChanged_ = function() { }; -/** - * @protected - */ -ol.Map.prototype.handleBrowserWindowResize = function() { - var size = goog.style.getSize(this.target_); - this.setSize(new ol.Size(size.width, size.height)); -}; - - /** * @private */ @@ -871,6 +862,16 @@ ol.Map.prototype.unfreezeRendering = function() { }; +/** + * Force a recalculation of the map viewport size. This should be called when + * third-party code changes the size of the map viewport. + */ +ol.Map.prototype.updateSize = function() { + var size = goog.style.getSize(this.target_); + this.setSize(new ol.Size(size.width, size.height)); +}; + + /** * @param {function(this: T)} f Function. * @param {T=} opt_obj Object.