2011-07-16 23:53:15 +02:00
|
|
|
var FlatProjection = DynmapProjection.extend({
|
|
|
|
fromLocationToLatLng: function(location) {
|
|
|
|
return new L.LatLng(-location.z, location.x, true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var FlatMapType = DynmapTileLayer.extend({
|
|
|
|
projection: new FlatProjection({}),
|
|
|
|
options: {
|
|
|
|
minZoom: 0,
|
|
|
|
maxZoom: 4
|
|
|
|
},
|
|
|
|
initialize: function(options) {
|
|
|
|
L.Util.setOptions(this, options);
|
|
|
|
},
|
|
|
|
getTileName: function(tilePoint, zoom) {
|
|
|
|
var tileName;
|
|
|
|
var dnprefix = '';
|
|
|
|
if(this.options.nightandday && this.dynmap.serverday) {
|
|
|
|
dnprefix = '_day';
|
2011-03-01 01:59:33 +01:00
|
|
|
}
|
2011-07-16 23:53:15 +02:00
|
|
|
tileName = this.options.prefix + dnprefix + '_128_' + tilePoint.x + '_' + tilePoint.y + '.png';
|
|
|
|
return tileName;
|
|
|
|
},
|
|
|
|
calculateTileSize: function(zoom) {
|
|
|
|
return Math.pow(2, 7+zoom);
|
|
|
|
}
|
|
|
|
})
|
2011-03-01 01:59:33 +01:00
|
|
|
|
2011-07-16 23:53:15 +02:00
|
|
|
/*
|
2011-03-06 14:45:26 +01:00
|
|
|
function FlatMapType(configuration) {
|
|
|
|
$.extend(this, configuration); }
|
2011-03-01 01:59:33 +01:00
|
|
|
FlatMapType.prototype = $.extend(new DynMapType(), {
|
|
|
|
constructor: FlatMapType,
|
|
|
|
projection: new FlatProjection(),
|
2011-07-16 23:53:15 +02:00
|
|
|
tileSize: 128.0,
|
2011-03-01 01:59:33 +01:00
|
|
|
minZoom: 0,
|
2011-05-13 08:05:20 +02:00
|
|
|
maxZoom: 3,
|
2011-03-06 14:45:26 +01:00
|
|
|
prefix: null,
|
2011-03-01 01:59:33 +01:00
|
|
|
getTile: function(coord, zoom, doc) {
|
2011-05-13 08:05:20 +02:00
|
|
|
var tileSize = 128;
|
|
|
|
var imgSize;
|
|
|
|
var tileName;
|
|
|
|
|
2011-05-30 00:24:46 +02:00
|
|
|
var dnprefix = '';
|
|
|
|
if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].nightandday && this.dynmap.serverday)
|
|
|
|
dnprefix = '_day';
|
2011-06-22 23:43:41 +02:00
|
|
|
var extrazoom = this.dynmap.world.extrazoomout;
|
|
|
|
if(zoom < extrazoom) {
|
|
|
|
var scale = 1 << (extrazoom-zoom);
|
|
|
|
var zprefix = "zzzzzzzzzzzz".substring(0, extrazoom-zoom);
|
2011-07-09 22:51:32 +02:00
|
|
|
if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].bigmap)
|
2011-06-22 23:43:41 +02:00
|
|
|
tileName = this.prefix + dnprefix + '_128/' + ((scale*coord.x) >> 5) + '_' + ((scale*coord.y) >> 5) +
|
|
|
|
'/' + zprefix + "_" + (scale*coord.x) + '_' + (scale*coord.y) + '.png';
|
|
|
|
else
|
|
|
|
tileName = zprefix + this.prefix + dnprefix + '_128_' + (scale*coord.x) + '_' + (scale*coord.y) + '.png';
|
|
|
|
imgSize = 128;
|
|
|
|
}
|
|
|
|
else {
|
2011-07-09 22:51:32 +02:00
|
|
|
if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].bigmap)
|
2011-06-22 23:43:41 +02:00
|
|
|
tileName = this.prefix + dnprefix + '_128/' + (coord.x >> 5) + '_' + (coord.y >> 5) +
|
|
|
|
'/' + coord.x + '_' + coord.y + '.png';
|
|
|
|
else
|
|
|
|
tileName = this.prefix + dnprefix + '_128_' + coord.x + '_' + coord.y + '.png';
|
|
|
|
imgSize = Math.pow(2, 7+zoom-extrazoom);
|
|
|
|
}
|
2011-05-13 08:05:20 +02:00
|
|
|
var tile = $('<div/>')
|
|
|
|
.addClass('tile')
|
2011-03-01 01:59:33 +01:00
|
|
|
.css({
|
2011-05-13 08:05:20 +02:00
|
|
|
width: tileSize + 'px',
|
|
|
|
height: tileSize + 'px'
|
|
|
|
});
|
|
|
|
var img = $('<img/>')
|
|
|
|
.attr('src', this.dynmap.getTileUrl(tileName))
|
|
|
|
.error(function() { img.hide(); })
|
|
|
|
.bind('load', function() { img.show(); })
|
|
|
|
.css({
|
|
|
|
width: imgSize +'px',
|
|
|
|
height: imgSize + 'px',
|
2011-03-01 01:59:33 +01:00
|
|
|
borderStyle: 'none'
|
|
|
|
})
|
2011-05-13 08:05:20 +02:00
|
|
|
.hide()
|
|
|
|
.appendTo(tile);
|
|
|
|
this.dynmap.registerTile(this, tileName, img);
|
2011-03-01 01:59:33 +01:00
|
|
|
//this.dynmap.unregisterTile(this, tileName);
|
|
|
|
return tile.get(0);
|
|
|
|
},
|
|
|
|
updateTileSize: function(zoom) {
|
2011-05-13 08:05:20 +02:00
|
|
|
var size;
|
2011-06-22 23:43:41 +02:00
|
|
|
var extrazoom = this.dynmap.world.extrazoomout;
|
2011-07-22 08:42:10 +02:00
|
|
|
var mapzoomin = this.mapzoomin;
|
2011-06-23 07:53:56 +02:00
|
|
|
this.projection.extrazoom = extrazoom;
|
2011-07-22 06:25:59 +02:00
|
|
|
this.maxZoom = mapzoomin + extrazoom;
|
2011-06-22 23:43:41 +02:00
|
|
|
if (zoom <= extrazoom) {
|
|
|
|
size = 128;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
size = Math.pow(2, 7+zoom-extrazoom);
|
|
|
|
}
|
2011-07-16 23:53:15 +02:00
|
|
|
this.tileSize = size;
|
2011-03-01 01:59:33 +01:00
|
|
|
}
|
|
|
|
});
|
2011-07-16 23:53:15 +02:00
|
|
|
*/
|
|
|
|
maptypes.FlatMapType = function(options) { return new FlatMapType(options); };
|