diff --git a/viewer/MinedMap.js b/viewer/MinedMap.js index 8548890..56011c9 100644 --- a/viewer/MinedMap.js +++ b/viewer/MinedMap.js @@ -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 MinedMap'; + 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); + }, }); diff --git a/viewer/index.html b/viewer/index.html index fa42dd2..09ba664 100644 --- a/viewer/index.html +++ b/viewer/index.html @@ -4,8 +4,8 @@ MinedMap - - + +