Add destroy() to Control.OverviewMap and add a check to map.destroy() to bail if it's already been called (by, say, window.onunload). Fixes #595.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2958 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -77,6 +77,47 @@ OpenLayers.Control.OverviewMap.prototype =
|
|||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
destroy: function() {
|
||||||
|
this.mapDiv.removeChild(this.extentRectangle);
|
||||||
|
this.extentRectangle = null;
|
||||||
|
this.rectEvents.destroy();
|
||||||
|
this.rectEvents = null;
|
||||||
|
|
||||||
|
this.ovmap.destroy();
|
||||||
|
this.ovmap = null;
|
||||||
|
|
||||||
|
this.element.removeChild(this.mapDiv);
|
||||||
|
this.mapDiv = null;
|
||||||
|
this.mapDivEvents.destroy();
|
||||||
|
this.mapDivEvents = null;
|
||||||
|
|
||||||
|
this.div.removeChild(this.element);
|
||||||
|
this.element = null;
|
||||||
|
this.elementEvents.destroy();
|
||||||
|
this.elementEvents = null;
|
||||||
|
|
||||||
|
if (this.maximizeDiv) {
|
||||||
|
OpenLayers.Event.stopObservingElement(this.maximizeDiv);
|
||||||
|
this.div.removeChild(this.maximizeDiv);
|
||||||
|
this.maximizeDiv = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.minimizeDiv) {
|
||||||
|
OpenLayers.Event.stopObservingElement(this.minimizeDiv);
|
||||||
|
this.div.removeChild(this.minimizeDiv);
|
||||||
|
this.minimizeDiv = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.map.events.unregister('moveend', this, this.update);
|
||||||
|
this.map.events.unregister("changebaselayer", this,
|
||||||
|
this.baseLayerDraw);
|
||||||
|
|
||||||
|
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type DOMElement
|
* @type DOMElement
|
||||||
|
|||||||
@@ -237,6 +237,10 @@ OpenLayers.Map.prototype = {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
destroy:function() {
|
destroy:function() {
|
||||||
|
// if unloadDestroy is null, we've already been destroyed
|
||||||
|
if (!this.unloadDestroy) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// map has been destroyed. dont do it again!
|
// map has been destroyed. dont do it again!
|
||||||
OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy);
|
OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy);
|
||||||
|
|||||||
Reference in New Issue
Block a user