mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
Use higher-resolution tiles on retina displays
This commit is contained in:
parent
22615f90aa
commit
e027f76d9b
1 changed files with 12 additions and 8 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue