diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-02-04 06:35:31 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-02-04 06:35:31 +0100 |
commit | e027f76d9b11721c9bf75313469df37e1d472a2c (patch) | |
tree | 17efb3f20b465ffe496e74e9016ec91281637856 /viewer | |
parent | 22615f90aa1fa3f0268f0b1d1ba3ef00b33090d5 (diff) | |
download | MinedMap-e027f76d9b11721c9bf75313469df37e1d472a2c.tar MinedMap-e027f76d9b11721c9bf75313469df37e1d472a2c.zip |
Use higher-resolution tiles on retina displays
Diffstat (limited to 'viewer')
-rw-r--r-- | viewer/MinedMap.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/viewer/MinedMap.js b/viewer/MinedMap.js index a949cce..f6be634 100644 --- a/viewer/MinedMap.js +++ b/viewer/MinedMap.js @@ -1,7 +1,9 @@ var MinedMapLayer = L.GridLayer.extend({ initialize: function (mipmaps, layer) { - this._mipmaps = mipmaps; - this._layer = layer; + this.mipmaps = mipmaps; + this.layer = layer; + + this.zoomOffset = L.Browser.retina ? 1 : 0; this.options.attribution = 'Generated by <a href="http://git.universe-factory.net/MinedMap/">MinedMap</a>'; @@ -18,16 +20,16 @@ var MinedMapLayer = L.GridLayer.extend({ tile.alt = ''; - var z = -coords.z; + var z = -(coords.z + this.zoomOffset); if (z < 0) z = 0; - var mipmap = this._mipmaps[z]; + var mipmap = this.mipmaps[z]; if (coords.x >= mipmap.info.minX && coords.x <= mipmap.info.maxX && coords.y >= mipmap.info.minZ && coords.y <= mipmap.info.maxZ && mipmap.regions[coords.y-mipmap.info.minZ][coords.x-mipmap.info.minX]) - tile.src = 'data/'+this._layer+'/'+z+'/r.'+coords.x+'.'+coords.y+'.png'; + tile.src = 'data/'+this.layer+'/'+z+'/r.'+coords.x+'.'+coords.y+'.png'; if (coords.z >= 0) L.DomUtil.addClass(tile, 'overzoomed'); @@ -44,12 +46,14 @@ var MinedMapLayer = L.GridLayer.extend({ }, _getTileSize: function () { - var map = this._map, zoom = map.getZoom(); + var map = this._map, zoom = map.getZoom() + this.zoomOffset; + + var base = (L.Browser.retina ? 256 : 512); if (zoom > 0) - return Math.round(map.getZoomScale(map.getZoom(), 0) * 512); + return Math.round(map.getZoomScale(zoom, 0) * base); else - return 512; + return base; }, _onTileRemove: function (e) { |