Fixed nightday and making use of options.mapzoomin and options.mapzoomout.
This commit is contained in:
parent
9f19ccf50c
commit
4f75bf691a
5 changed files with 58 additions and 52 deletions
|
|
@ -124,15 +124,47 @@ var DynmapTileLayer = L.TileLayer.extend({
|
|||
this._removeOtherTiles(tileBounds);
|
||||
}
|
||||
},
|
||||
calculateTileSize: function(zoom) {
|
||||
/*calculateTileSize: function(zoom) {
|
||||
return this.options.tileSize;
|
||||
},*/
|
||||
calculateTileSize: function(zoom) {
|
||||
// zoomoutlevel: 0 when izoom > mapzoomin, else mapzoomin - izoom (which ranges from 0 till mapzoomin)
|
||||
var izoom = this.options.maxZoom - zoom;
|
||||
var zoominlevel = Math.max(0, this.options.mapzoomin - izoom);
|
||||
return 128 << zoominlevel;
|
||||
},
|
||||
setTileSize: function(tileSize) {
|
||||
this.options.tileSize = tileSize;
|
||||
this._tiles = {};
|
||||
this._createTileProto();
|
||||
},
|
||||
updateTileSize: function(zoom) {}
|
||||
updateTileSize: function(zoom) {},
|
||||
|
||||
// Some helper functions.
|
||||
zoomprefix: function(amount) {
|
||||
// amount == 0 -> ''
|
||||
// amount == 1 -> 'z_'
|
||||
// amount == 2 -> 'zz_'
|
||||
return 'zzzzzzzzzzzzzzzzzzzzzz'.substr(0, amount) + (amount === 0 ? '' : '_');
|
||||
},
|
||||
getTileInfo: function(tilePoint, zoom) {
|
||||
// zoom: max zoomed in = this.options.maxZoom, max zoomed out = 0
|
||||
// izoom: max zoomed in = 0, max zoomed out = this.options.maxZoom
|
||||
// zoomoutlevel: 0 when izoom < mapzoomin, else izoom - mapzoomin (which ranges from 0 till mapzoomout)
|
||||
var izoom = this.options.maxZoom - zoom;
|
||||
var zoomoutlevel = Math.max(0, izoom - this.options.mapzoomin);
|
||||
var scale = 1 << zoomoutlevel;
|
||||
var zoomprefix = this.zoomprefix(zoomoutlevel);
|
||||
return {
|
||||
prefix: this.options.prefix,
|
||||
nightday: (this.options.nightandday && this.options.dynmap.serverday) ? '_day' : '',
|
||||
scaledx: (scale*tilePoint.x) >> 5,
|
||||
scaledy: (-scale*tilePoint.y) >> 5,
|
||||
zoom: this.zoomprefix(zoomoutlevel),
|
||||
x: scale*tilePoint.x,
|
||||
y: -scale*tilePoint.y
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
function loadjs(url, completed) {
|
||||
|
|
@ -215,8 +247,8 @@ function namedReplace(str, obj)
|
|||
break;
|
||||
}
|
||||
if (variableBegin < variableEnd) {
|
||||
var variableName = str.substring(variableBegin+1, variableEnd-1);
|
||||
result += str.substring(startIndex, variableBegin-1);
|
||||
var variableName = str.substring(variableBegin+1, variableEnd);
|
||||
result += str.substring(startIndex, variableBegin);
|
||||
result += obj[variableName];
|
||||
} else /* found '{}' */ {
|
||||
result += str.substring(startIndex, variableBegin-1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue