Made use of mapzoomout+mapzoomin on all maptypes + simplified the client code of the individual maps.
This commit is contained in:
parent
4f75bf691a
commit
ce00242253
4 changed files with 59 additions and 79 deletions
|
|
@ -1,6 +1,9 @@
|
|||
var FlatProjection = DynmapProjection.extend({
|
||||
fromLocationToLatLng: function(location) {
|
||||
return new L.LatLng(-location.z, location.x, true);
|
||||
return new L.LatLng(
|
||||
-location.z / (8 << this.options.mapzoomout),
|
||||
location.x / (8 << this.options.mapzoomout),
|
||||
true);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -10,40 +13,16 @@ var FlatMapType = DynmapTileLayer.extend({
|
|||
maxZoom: 4
|
||||
},
|
||||
initialize: function(options) {
|
||||
options.maxZoom = options.mapzoomin + options.world.extrazoomout;
|
||||
options.maxzoomout = options.mapzoomout || options.world.extrazoomout;
|
||||
options.maxZoom = options.mapzoomin + options.maxzoomout;
|
||||
L.Util.setOptions(this, options);
|
||||
this.projection = new FlatProjection({extrazoom: this.options.world.extrazoomout});
|
||||
this.projection = new FlatProjection({mapzoomout: options.mapzoomout});
|
||||
},
|
||||
getTileName: function(tilePoint, zoom) {
|
||||
var tileName;
|
||||
var dnprefix = '';
|
||||
if(this.options.nightandday && this.options.dynmap.serverday) {
|
||||
dnprefix = '_day';
|
||||
}
|
||||
var extrazoom = this.options.world.extrazoomout;
|
||||
if(zoom < extrazoom) {
|
||||
var scale = 1 << (extrazoom-zoom);
|
||||
var zprefix = "zzzzzzzzzzzz".substring(0, extrazoom-zoom);
|
||||
if(this.options.bigmap) {
|
||||
tileName = this.options.prefix + dnprefix + '_128/' + ((scale*tilePoint.x) >> 5) + '_' + ((scale*tilePoint.y) >> 5) + '/' + zprefix + "_" + (scale*tilePoint.x) + '_' + (scale*tilePoint.y) + '.png';
|
||||
} else {
|
||||
tileName = zprefix + this.options.prefix + dnprefix + '_128_' + (scale*tilePoint.x) + '_' + (scale*tilePoint.y) + '.png';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(this.options.bigmap) {
|
||||
tileName = this.options.prefix + dnprefix + '_128/' + (tilePoint.x >> 5) + '_' + (tilePoint.y >> 5) + '/' + tilePoint.x + '_' + tilePoint.y + '.png';
|
||||
} else {
|
||||
tileName = this.options.prefix + dnprefix + '_128_' + tilePoint.x + '_' + tilePoint.y + '.png';
|
||||
}
|
||||
}
|
||||
return tileName;
|
||||
},
|
||||
calculateTileSize: function(zoom) {
|
||||
var extrazoom = this.options.world.extrazoomout;
|
||||
return (zoom < extrazoom)
|
||||
? 128
|
||||
: Math.pow(2, 7+zoom-extrazoom);
|
||||
return namedReplace(this.options.bigmap
|
||||
? '{prefix}{nightday}_128/{scaledx}_{scaledy}/{zoom}_{x}_{y}.png'
|
||||
: '{zoom}{prefix}{nightday}_128_{x}_{y}.png'
|
||||
, this.getTileInfo(tilePoint, zoom));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue