From 492b14414776b9bf4f24d94cd6dfb521001b77cd Mon Sep 17 00:00:00 2001 From: euzuro Date: Wed, 20 Sep 2006 11:24:16 +0000 Subject: [PATCH] add code so that if initialize() is called on a marker that already has an icon created, it resets the icon's data but preserves its DOMElement div git-svn-id: http://svn.openlayers.org/trunk/openlayers@1496 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Marker.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index 292a1576e7..7e672f2cd6 100644 --- a/lib/OpenLayers/Marker.js +++ b/lib/OpenLayers/Marker.js @@ -30,7 +30,16 @@ OpenLayers.Marker.prototype = { initialize: function(lonlat, icon) { if (arguments.length > 0) { this.lonlat = lonlat; - this.icon = (icon) ? icon : OpenLayers.Marker.defaultIcon(); + + var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon(); + if (this.icon == null) { + this.icon = newIcon; + } else { + this.icon.url = newIcon.url; + this.icon.size = newIcon.size; + this.icon.offset = newIcon.offset; + this.icon.calculateOffset = newIcon.calculateOffset; + } this.events = new OpenLayers.Events(this, this.icon.imageDiv, null); } },