applying (yet another) patch for #549. this one eliminates the double-destruction of the map due to the unload of window
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2874 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -33,6 +33,12 @@ OpenLayers.Map.prototype = {
|
|||||||
/** @type OpenLayers.Events */
|
/** @type OpenLayers.Events */
|
||||||
events: null,
|
events: null,
|
||||||
|
|
||||||
|
/** function that is called to destroy the map on page unload. stored
|
||||||
|
* here so that if map is manually destroyed, we can unregister this.
|
||||||
|
*
|
||||||
|
* @type Function */
|
||||||
|
unloadDestroy: null,
|
||||||
|
|
||||||
/** the div that our map lives in
|
/** the div that our map lives in
|
||||||
*
|
*
|
||||||
* @type DOMElement */
|
* @type DOMElement */
|
||||||
@@ -212,10 +218,11 @@ OpenLayers.Map.prototype = {
|
|||||||
|
|
||||||
this.popups = new Array();
|
this.popups = new Array();
|
||||||
|
|
||||||
|
this.unloadDestroy = this.destroy.bindAsEventListener(this);
|
||||||
|
|
||||||
|
|
||||||
// always call map.destroy()
|
// always call map.destroy()
|
||||||
OpenLayers.Event.observe(window,
|
OpenLayers.Event.observe(window, 'unload', this.unloadDestroy);
|
||||||
'unload',
|
|
||||||
this.destroy.bindAsEventListener(this));
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -223,6 +230,11 @@ OpenLayers.Map.prototype = {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
destroy:function() {
|
destroy:function() {
|
||||||
|
|
||||||
|
// map has been destroyed. dont do it again!
|
||||||
|
OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy);
|
||||||
|
this.unloadDestroy = null;
|
||||||
|
|
||||||
if (this.layers != null) {
|
if (this.layers != null) {
|
||||||
for(var i=0; i< this.layers.length; i++) {
|
for(var i=0; i< this.layers.length; i++) {
|
||||||
//pass 'false' to destroy so that map wont try to set a new
|
//pass 'false' to destroy so that map wont try to set a new
|
||||||
@@ -241,6 +253,10 @@ OpenLayers.Map.prototype = {
|
|||||||
this.div.removeChild(this.viewPortDiv);
|
this.div.removeChild(this.viewPortDiv);
|
||||||
}
|
}
|
||||||
this.viewPortDiv = null;
|
this.viewPortDiv = null;
|
||||||
|
|
||||||
|
this.events.destroy();
|
||||||
|
this.events = null;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user