diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index b7b4dbdff4..4fc3386618 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -373,8 +373,10 @@ OpenLayers.Map = OpenLayers.Class({ // Else updateSize on catching the window's resize // Note that this is ok, as updateSize() does nothing if the // map's size has not actually changed. + this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize, + this); OpenLayers.Event.observe(window, 'resize', - OpenLayers.Function.bind(this.updateSize, this)); + this.updateSizeDestroy); } // only append link stylesheet if the theme property is set @@ -434,6 +436,14 @@ OpenLayers.Map = OpenLayers.Class({ * so that if map is manually destroyed, we can unregister this. */ unloadDestroy: null, + + /** + * Method: updateSizeDestroy + * When the map is destroyed, we need to stop listening to updateSize + * events: this method stores the function we need to unregister in + * non-IE browsers. + */ + updateSizeDestroy: null, /** * APIMethod: destroy @@ -449,6 +459,13 @@ OpenLayers.Map = OpenLayers.Class({ OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy); this.unloadDestroy = null; + if (this.updateSizeDestroy) { + OpenLayers.Event.stopObserving(window, 'resize', + this.updateSizeDestroy); + } else { + this.events.unregister("resize", this, this.updateSize); + } + if (this.layers != null) { for (var i = this.layers.length - 1; i>=0; --i) { //pass 'false' to destroy so that map wont try to set a new