ImageOverlay accept ImageElement

This commit is contained in:
Unknown 2017-12-03 13:20:18 +02:00
parent abb14f0b8c
commit 39c3bf7ed3

View File

@ -179,9 +179,12 @@ export var ImageOverlay = Layer.extend({
},
_initImage: function () {
var img = this._image = DomUtil.create('img',
'leaflet-image-layer ' + (this._zoomAnimated ? 'leaflet-zoom-animated ' : '') +
(this.options.className || ''));
var wasElementSupplied = this._url.tagName === 'IMG';
var img = this._image = wasElementSupplied ? this._url : DomUtil.create('img');
DomUtil.addClass(img, 'leaflet-image-layer');
if (this._zoomAnimated) { DomUtil.addClass(img, 'leaflet-zoom-animated'); }
if (this.options.className) { DomUtil.addClass(img, this.options.className); }
img.onselectstart = Util.falseFn;
img.onmousemove = Util.falseFn;
@ -199,6 +202,8 @@ export var ImageOverlay = Layer.extend({
this._updateZIndex();
}
if (wasElementSupplied) { return; }
img.src = this._url;
img.alt = this.options.alt;
},