lib/leaflet/src/layer/marker/Icon.js in leaflet-js-0.6.beta4 vs lib/leaflet/src/layer/marker/Icon.js in leaflet-js-0.7.0

- old
+ new

@@ -8,11 +8,11 @@ iconUrl: (String) (required) iconRetinaUrl: (String) (optional, used for retina devices if detected) iconSize: (Point) (can be set through CSS) iconAnchor: (Point) (centered by default, can be set in CSS with negative margins) popupAnchor: (Point) (if not specified, popup opens in the anchor point) - shadowUrl: (Point) (no shadow by default) + shadowUrl: (String) (no shadow by default) shadowRetinaUrl: (String) (optional, used for retina devices if detected) shadowSize: (Point) shadowAnchor: (Point) */ className: '' @@ -20,29 +20,34 @@ initialize: function (options) { L.setOptions(this, options); }, - createIcon: function () { - return this._createIcon('icon'); + createIcon: function (oldIcon) { + return this._createIcon('icon', oldIcon); }, - createShadow: function () { - return this._createIcon('shadow'); + createShadow: function (oldIcon) { + return this._createIcon('shadow', oldIcon); }, - _createIcon: function (name) { + _createIcon: function (name, oldIcon) { var src = this._getIconUrl(name); if (!src) { if (name === 'icon') { throw new Error('iconUrl not set in Icon options (see the docs).'); } return null; } - var img = this._createImg(src); + var img; + if (!oldIcon || oldIcon.tagName !== 'IMG') { + img = this._createImg(src); + } else { + img = this._createImg(src, oldIcon); + } this._setIconStyles(img, name); return img; }, @@ -72,20 +77,12 @@ img.style.width = size.x + 'px'; img.style.height = size.y + 'px'; } }, - _createImg: function (src) { - var el; - - if (!L.Browser.ie6) { - el = document.createElement('img'); - el.src = src; - } else { - el = document.createElement('div'); - el.style.filter = - 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '")'; - } + _createImg: function (src, el) { + el = el || document.createElement('img'); + el.src = src; return el; }, _getIconUrl: function (name) { if (L.Browser.retina && this.options[name + 'RetinaUrl']) {