viewer: update Leaflet to 1.6.0

This commit is contained in:
Matthias Schiffer 2020-06-20 14:04:59 +02:00
parent 03ae9cf302
commit 3c837bb92e
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
16 changed files with 234 additions and 70 deletions

View file

@ -5,8 +5,13 @@ var MinedMapLayer = L.GridLayer.extend({
this.zoomOffset = L.Browser.retina ? 1 : 0;
this.options.tileSize = L.Browser.retina ? 256 : 512;
this.options.attribution = 'Generated by <a href="https://github.com/NeoRaider/MinedMap">MinedMap</a>';
this.options.minZoom = -(mipmaps.length-1 + this.zoomOffset);
this.options.maxNativeZoom = 0;
// for https://github.com/Leaflet/Leaflet/issues/137
if (!L.Browser.android) {
this.on('tileunload', this._onTileRemove);
}
@ -18,8 +23,18 @@ var MinedMapLayer = L.GridLayer.extend({
tile.onload = L.bind(this._tileOnLoad, this, done, tile);
tile.onerror = L.bind(this._tileOnError, this, done, tile);
/*
Alt tag is set to empty string to keep screen readers from reading URL and for compliance reasons
http://www.w3.org/TR/WCAG20-TECHS/H67
*/
tile.alt = '';
/*
Set role="presentation" to force screen readers to ignore this
https://www.w3.org/TR/wai-aria/roles#textalternativecomputation
*/
tile.setAttribute('role', 'presentation');
var z = -(coords.z + this.zoomOffset);
if (z < 0)
z = 0;
@ -38,43 +53,50 @@ var MinedMapLayer = L.GridLayer.extend({
},
_tileOnLoad: function (done, tile) {
done(null, tile);
if (L.Browser.ielt9)
setTimeout(Util.bind(done, this, null, tile), 0);
else
done(null, tile);
},
_tileOnError: function (done, tile, e) {
done(e, tile);
},
_getTileSize: function () {
var map = this._map, zoom = map.getZoom() + this.zoomOffset;
var base = (L.Browser.retina ? 256 : 512);
if (zoom > 0)
return Math.round(map.getZoomScale(zoom, 0) * base);
else
return base;
},
_onTileRemove: function (e) {
e.tile.onload = null;
e.tile.src = L.Util.emptyImageUrl;
},
_abortLoading: function () {
var i, tile;
for (i in this._tiles) {
tile = this._tiles[i].el;
if (this._tiles[i].coords.z !== this._tileZoom) {
tile = this._tiles[i].el;
tile.onload = L.Util.falseFn;
tile.onerror = L.Util.falseFn;
tile.onload = L.Util.falseFn;
tile.onerror = L.Util.falseFn;
if (!tile.complete) {
tile.src = L.Util.emptyImageUrl;
L.DomUtil.remove(tile);
if (!tile.complete) {
tile.src = L.Util.emptyImageUrl;
L.DomUtil.remove(tile);
}
}
}
}
},
_removeTile: function (key) {
var tile = this._tiles[key];
if (!tile) { return; }
// Cancels any pending http requests associated with the tile
// unless we're on Android's stock browser,
// see https://github.com/Leaflet/Leaflet/issues/137
if (!L.Browser.androidStock) {
tile.el.setAttribute('src', L.Util.emptyImageUrl);
}
return L.GridLayer.prototype._removeTile.call(this, key);
},
});