Add an updateSize method

We need a non-private/protected method to call when the map viewport size changes.
This commit is contained in:
Tim Schaub
2013-04-10 12:47:06 -06:00
parent ae5d1cee1e
commit b499f71d97

View File

@@ -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.