Fix(GridLayer): Do not fire 'tileload' event if tile src is empty image (#6025)
* do not fire 'load' event if tile src is the empty image (i.e. L.Util.emptyImageUrl) * add TileLayer setUrl test
This commit is contained in:
parent
2dc70945f8
commit
ad8fc9c36b
@ -455,4 +455,27 @@ describe('TileLayer', function () {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('#setUrl', function () {
|
||||
it('fires only one load event', function (done) {
|
||||
var layer = L.tileLayer(placeKitten).addTo(map);
|
||||
var counts = {
|
||||
load: 0,
|
||||
tileload: 0
|
||||
};
|
||||
map.setView([0, 0], 1);
|
||||
|
||||
layer.on('tileload load', function (e) {
|
||||
counts[e.type]++;
|
||||
});
|
||||
|
||||
layer.setUrl(placeKitten);
|
||||
|
||||
setTimeout(function () {
|
||||
expect(counts.load).to.equal(1);
|
||||
expect(counts.tileload).to.equal(8);
|
||||
done();
|
||||
}, 250);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -842,7 +842,7 @@ export var GridLayer = Layer.extend({
|
||||
},
|
||||
|
||||
_tileReady: function (coords, err, tile) {
|
||||
if (!this._map) { return; }
|
||||
if (!this._map || tile.getAttribute('src') === Util.emptyImageUrl) { return; }
|
||||
|
||||
if (err) {
|
||||
// @event tileerror: TileErrorEvent
|
||||
|
Loading…
Reference in New Issue
Block a user