2011-07-18 03:40:24 +02:00
|
|
|
var KzedProjection = DynmapProjection.extend({
|
|
|
|
fromLocationToLatLng: function(location) {
|
|
|
|
var dx = location.x;
|
|
|
|
var dy = location.y - 127;
|
|
|
|
var dz = location.z;
|
|
|
|
var px = dx + dz;
|
|
|
|
var py = dx - dz - dy;
|
2011-07-24 17:11:34 +02:00
|
|
|
var scale = 1 << this.options.mapzoomout;
|
2011-07-18 03:40:24 +02:00
|
|
|
|
2011-07-24 17:11:34 +02:00
|
|
|
var xx = (128 - px) / scale;
|
|
|
|
var yy = py / scale;
|
|
|
|
return new L.LatLng(xx, yy, true);
|
2011-07-18 03:40:24 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var KzedMapType = DynmapTileLayer.extend({
|
|
|
|
options: {
|
|
|
|
minZoom: 0,
|
2011-08-02 07:07:17 +02:00
|
|
|
maxZoom: 4,
|
|
|
|
errorTileUrl: 'images/blank.png'
|
2011-07-18 03:40:24 +02:00
|
|
|
},
|
|
|
|
initialize: function(options) {
|
2011-07-24 17:11:34 +02:00
|
|
|
options.mapzoomout = options.mapzoomout || options.world.extrazoomout;
|
|
|
|
options.maxZoom = options.mapzoomin + options.mapzoomout;
|
2011-07-18 03:40:24 +02:00
|
|
|
L.Util.setOptions(this, options);
|
2011-07-24 17:11:34 +02:00
|
|
|
this.projection = new KzedProjection({mapzoomout: this.options.mapzoomout});
|
2011-07-18 03:40:24 +02:00
|
|
|
},
|
|
|
|
getTileName: function(tilePoint, zoom) {
|
2011-07-24 17:11:34 +02:00
|
|
|
var info = this.getTileInfo(tilePoint, zoom);
|
|
|
|
return namedReplace(this.options.bigmap
|
|
|
|
? '{prefix}{nightday}/{scaledx}_{scaledy}/{zoom}_{x}_{y}.png'
|
|
|
|
: '{zoom}{prefix}{nightday}_{x}_{y}.png'
|
|
|
|
, this.getTileInfo(tilePoint, zoom));
|
2011-07-18 03:40:24 +02:00
|
|
|
},
|
2011-07-24 17:11:34 +02:00
|
|
|
getTileInfo: function(tilePoint, zoom) {
|
|
|
|
// Custom tile-info-calculation for KzedMap: *128 and >>12
|
|
|
|
var izoom = this.options.maxZoom - zoom;
|
|
|
|
var zoomoutlevel = Math.max(0, izoom - this.options.mapzoomin);
|
|
|
|
var scale = 1 << zoomoutlevel;
|
|
|
|
var zoomprefix = this.zoomprefix(zoomoutlevel);
|
|
|
|
var x = -scale*tilePoint.x*128;
|
|
|
|
var y = scale*tilePoint.y*128;
|
|
|
|
return {
|
|
|
|
prefix: this.options.prefix,
|
|
|
|
nightday: (this.options.nightandday && this.options.dynmap.serverday) ? '_day' : '',
|
|
|
|
scaledx: x >> 12,
|
|
|
|
scaledy: y >> 12,
|
|
|
|
zoom: this.zoomprefix(zoomoutlevel),
|
|
|
|
x: x,
|
|
|
|
y: y
|
|
|
|
};
|
2011-07-18 03:40:24 +02:00
|
|
|
}
|
|
|
|
});
|
2011-02-06 15:09:15 +01:00
|
|
|
|
|
|
|
maptypes.KzedMapType = function(configuration) { return new KzedMapType(configuration); };
|