diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 8b0ddf9e54..f976aa4ab4 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -31,6 +31,9 @@ OpenLayers.Layer.prototype = { * the Javascript garbage cleaner can not take care of on its own. */ destroy: function() { + if (this.map != null) { + this.map.removeLayer(this); + } this.map = null; },