Add zooming to flat map (why not? :) )
This commit is contained in:
parent
1951a57fd3
commit
f7baca7a83
1 changed files with 26 additions and 10 deletions
|
|
@ -18,25 +18,41 @@ FlatMapType.prototype = $.extend(new DynMapType(), {
|
||||||
projection: new FlatProjection(),
|
projection: new FlatProjection(),
|
||||||
tileSize: new google.maps.Size(128.0, 128.0),
|
tileSize: new google.maps.Size(128.0, 128.0),
|
||||||
minZoom: 0,
|
minZoom: 0,
|
||||||
maxZoom: 0,
|
maxZoom: 3,
|
||||||
prefix: null,
|
prefix: null,
|
||||||
getTile: function(coord, zoom, doc) {
|
getTile: function(coord, zoom, doc) {
|
||||||
var tileName;
|
var tileSize = 128;
|
||||||
var tile = $('<img/>')
|
var imgSize;
|
||||||
.attr('src', this.dynmap.getTileUrl(tileName = this.prefix + '_128_' + coord.x + '_' + coord.y + '.png'))
|
var tileName;
|
||||||
.error(function() { tile.hide(); })
|
|
||||||
.bind('load', function() { tile.show(); })
|
tileName = this.prefix + '_128_' + coord.x + '_' + coord.y + '.png';
|
||||||
|
|
||||||
|
imgSize = Math.pow(2, 6+zoom);
|
||||||
|
var tile = $('<div/>')
|
||||||
|
.addClass('tile')
|
||||||
.css({
|
.css({
|
||||||
width: '128px',
|
width: tileSize + 'px',
|
||||||
height: '128px',
|
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',
|
||||||
borderStyle: 'none'
|
borderStyle: 'none'
|
||||||
})
|
})
|
||||||
.hide();
|
.hide()
|
||||||
this.dynmap.registerTile(this, tileName, tile);
|
.appendTo(tile);
|
||||||
|
this.dynmap.registerTile(this, tileName, img);
|
||||||
//this.dynmap.unregisterTile(this, tileName);
|
//this.dynmap.unregisterTile(this, tileName);
|
||||||
return tile.get(0);
|
return tile.get(0);
|
||||||
},
|
},
|
||||||
updateTileSize: function(zoom) {
|
updateTileSize: function(zoom) {
|
||||||
|
var size;
|
||||||
|
size = Math.pow(2, 6+zoom);
|
||||||
|
this.tileSize = new google.maps.Size(size, size);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue