diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index 88482d953e..3e0845eb5e 100644 --- a/lib/OpenLayers/Marker.js +++ b/lib/OpenLayers/Marker.js @@ -78,6 +78,7 @@ OpenLayers.Marker = OpenLayers.Class({ this.icon.offset = newIcon.offset; this.icon.calculateOffset = newIcon.calculateOffset; } + this.events = new OpenLayers.Events(this, this.icon.imageDiv, null); }, /** @@ -93,6 +94,9 @@ OpenLayers.Marker = OpenLayers.Class({ this.map = null; + this.events.destroy(); + this.events = null; + if (this.icon != null) { this.icon.destroy(); this.icon = null; @@ -111,9 +115,6 @@ OpenLayers.Marker = OpenLayers.Class({ * location passed-in */ draw: function(px) { - if (!this.events) { - this.events = new OpenLayers.Events(this, this.icon.imageDiv, null); - } return this.icon.draw(px); }, @@ -125,10 +126,6 @@ OpenLayers.Marker = OpenLayers.Class({ if (this.icon != null) { this.icon.erase(); } - if (this.events) { - this.events.destroy(); - this.events = null; - } }, /**