2011-03-01 01:59:33 +01:00
|
|
|
function FlatProjection() {}
|
|
|
|
FlatProjection.prototype = {
|
|
|
|
fromLatLngToPoint: function(latLng) {
|
2011-05-13 23:14:50 +02:00
|
|
|
return new google.maps.Point(latLng.lat()*config.tileWidth, latLng.lng()*config.tileHeight);
|
2011-03-01 01:59:33 +01:00
|
|
|
},
|
|
|
|
fromPointToLatLng: function(point) {
|
2011-05-13 23:14:50 +02:00
|
|
|
return new google.maps.LatLng(point.x/config.tileWidth, point.y/config.tileHeight);
|
2011-03-01 01:59:33 +01:00
|
|
|
},
|
|
|
|
fromWorldToLatLng: function(x, y, z) {
|
2011-05-13 23:14:50 +02:00
|
|
|
return new google.maps.LatLng(-z / config.tileWidth, x / config.tileHeight);
|
2011-03-01 01:59:33 +01: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(),
|
|
|
|
tileSize: new google.maps.Size(128.0, 128.0),
|
|
|
|
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';
|
|
|
|
|
|
|
|
tileName = this.prefix + dnprefix + '_128_' + coord.x + '_' + coord.y + '.png';
|
2011-05-13 23:14:50 +02:00
|
|
|
imgSize = Math.pow(2, 7+zoom);
|
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-05-13 23:14:50 +02:00
|
|
|
size = Math.pow(2, 7+zoom);
|
2011-05-13 08:05:20 +02:00
|
|
|
this.tileSize = new google.maps.Size(size, size);
|
2011-03-01 01:59:33 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
maptypes.FlatMapType = function(configuration) { return new FlatMapType(configuration); };
|