Add an updateSize method
We need a non-private/protected method to call when the map viewport size changes.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user