dynmap/web/js/flatmap.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

function FlatProjection() {}
FlatProjection.prototype = {
fromLatLngToPoint: function(latLng) {
return new google.maps.Point(latLng.lat()*128.0, latLng.lng()*128.0);
},
fromPointToLatLng: function(point) {
return new google.maps.LatLng(point.x/128.0, point.y/128.0);
},
fromWorldToLatLng: function(x, y, z) {
return new google.maps.LatLng(x / 128.0, z / 128.0);
}
};
2011-03-06 14:45:26 +01:00
function FlatMapType(configuration) {
$.extend(this, configuration); }
FlatMapType.prototype = $.extend(new DynMapType(), {
constructor: FlatMapType,
projection: new FlatProjection(),
tileSize: new google.maps.Size(128.0, 128.0),
minZoom: 0,
maxZoom: 0,
2011-03-06 14:45:26 +01:00
prefix: null,
getTile: function(coord, zoom, doc) {
var tileName;
var tile = $('<img/>')
2011-03-06 14:45:26 +01:00
.attr('src', this.dynmap.getTileUrl(tileName = this.prefix + '_128_' + coord.x + '_' + coord.y + '.png'))
.error(function() { tile.hide(); })
.bind('load', function() { tile.show(); })
.css({
width: '128px',
height: '128px',
borderStyle: 'none'
})
.hide();
this.dynmap.registerTile(this, tileName, tile);
//this.dynmap.unregisterTile(this, tileName);
return tile.get(0);
},
updateTileSize: function(zoom) {
}
});
maptypes.FlatMapType = function(configuration) { return new FlatMapType(configuration); };