diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index da4dcd9670..e894727d48 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -96,6 +96,8 @@ OpenLayers.Map.prototype = { this.popups = new Array(); + this.updateSize(); + // always call map.destroy() Event.observe(window, 'unload', this.destroy.bindAsEventListener(this)); @@ -198,18 +200,19 @@ OpenLayers.Map.prototype = { * @returns {OpenLayers.Size} */ getSize: function () { - // should this be cached? - var size = new OpenLayers.Size( + return this.size; + }, + + updateSize: function() { + this.size = new OpenLayers.Size( this.div.clientWidth, this.div.clientHeight); // Workaround for the fact that hidden elements return 0 for size. - if (size.w == 0 && size.h == 0) { - size.w = parseInt(this.div.style.width); - size.h = parseInt(this.div.style.height); + if (this.size.w == 0 && this.size.h == 0) { + this.size.w = parseInt(this.div.style.width); + this.size.h = parseInt(this.div.style.height); } - return size; }, - /** * @return {OpenLayers.LonLat} */