Add className option for ImageOverlay (#5555)
This commit is contained in:
parent
6bfa764cb0
commit
a3ec8047b3
@ -30,7 +30,8 @@ describe('ImageOverlay', function () {
|
||||
map.setView(new L.LatLng(55.8, 37.6), 6); // view needs to be set so when layer is added it is initilized
|
||||
|
||||
overlay = L.imageOverlay(blankUrl, [[40.712216, -74.22655], [40.773941, -74.12544]], {
|
||||
errorOverlayUrl: errorUrl
|
||||
errorOverlayUrl: errorUrl,
|
||||
className: 'my-custom-image-class'
|
||||
});
|
||||
map.addLayer(overlay);
|
||||
|
||||
@ -76,6 +77,12 @@ describe('ImageOverlay', function () {
|
||||
expect(overlay._image.src).to.be(errorUrl);
|
||||
});
|
||||
});
|
||||
|
||||
describe('className', function () {
|
||||
it('should set image\'s class', function () {
|
||||
expect(L.DomUtil.hasClass(overlay._image, 'my-custom-image-class')).to.be(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setZIndex', function () {
|
||||
|
@ -47,7 +47,11 @@ export var ImageOverlay = Layer.extend({
|
||||
|
||||
// @option zIndex: Number = 1
|
||||
// The explicit [zIndex](https://developer.mozilla.org/docs/Web/CSS/CSS_Positioning/Understanding_z_index) of the tile layer.
|
||||
zIndex: 1
|
||||
zIndex: 1,
|
||||
|
||||
// @option className: String = ''
|
||||
// A custom class name to assign to the image. Empty by default.
|
||||
className: '',
|
||||
},
|
||||
|
||||
initialize: function (url, bounds, options) { // (String, LatLngBounds, Object)
|
||||
@ -176,7 +180,8 @@ export var ImageOverlay = Layer.extend({
|
||||
|
||||
_initImage: function () {
|
||||
var img = this._image = DomUtil.create('img',
|
||||
'leaflet-image-layer ' + (this._zoomAnimated ? 'leaflet-zoom-animated' : ''));
|
||||
'leaflet-image-layer ' + (this._zoomAnimated ? 'leaflet-zoom-animated' : '') +
|
||||
(this.options.className || ''));
|
||||
|
||||
img.onselectstart = Util.falseFn;
|
||||
img.onmousemove = Util.falseFn;
|
||||
|
Loading…
Reference in New Issue
Block a user