mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-24 17:47:40 +01:00
Fix tile updating
This commit is contained in:
parent
94ecd3f495
commit
ca9009e33f
@ -80,17 +80,6 @@ var DynmapTileLayer = L.TileLayer.extend({
|
||||
_loadQueue: [],
|
||||
_loadingTiles: [],
|
||||
|
||||
getTileUrl: function(coords) {
|
||||
var tileName = this.getTileName(coords),
|
||||
url = this._cachedTileUrls[tileName];
|
||||
|
||||
if (!url) {
|
||||
this._cachedTileUrls[tileName] = url = this.options.dynmap.getTileUrl(tileName);
|
||||
}
|
||||
|
||||
return url;
|
||||
},
|
||||
|
||||
createTile: function(coords, done) {
|
||||
var me = this,
|
||||
tile = document.createElement('img');
|
||||
@ -188,6 +177,24 @@ var DynmapTileLayer = L.TileLayer.extend({
|
||||
L.TileLayer.prototype._removeTile.call(this, key);
|
||||
},
|
||||
|
||||
getTileUrl: function(coords, timestamp) {
|
||||
return this.getTileUrlFromName(this.getTileName(coords), timestamp);
|
||||
},
|
||||
|
||||
getTileUrlFromName(tileName, timestamp) {
|
||||
var url = this._cachedTileUrls[tileName];
|
||||
|
||||
if (!url) {
|
||||
this._cachedTileUrls[tileName] = url = this.options.dynmap.getTileUrl(tileName);
|
||||
}
|
||||
|
||||
if(typeof timestamp !== 'undefined') {
|
||||
url += (url.indexOf('?') === -1 ? '?timestamp=' + timestamp : '×tamp=' + timestamp);
|
||||
}
|
||||
|
||||
return url;
|
||||
},
|
||||
|
||||
getProjection: function() {
|
||||
return this.projection;
|
||||
},
|
||||
@ -207,26 +214,18 @@ var DynmapTileLayer = L.TileLayer.extend({
|
||||
next.src = next.url;
|
||||
},
|
||||
|
||||
onTileUpdated: function(tile, tileName) {
|
||||
var src = this.dynmap.getTileUrl(tileName);
|
||||
tile.attr('src', src);
|
||||
tile.show();
|
||||
},
|
||||
|
||||
getTileName: function(coords) {
|
||||
throw "getTileName not implemented";
|
||||
},
|
||||
|
||||
updateNamedTile: function(name) {
|
||||
updateNamedTile: function(name, timestamp) {
|
||||
var tile = this._namedTiles[name];
|
||||
delete this._cachedTileUrls[name];
|
||||
if (tile) {
|
||||
this.updateTile(tile);
|
||||
}
|
||||
},
|
||||
|
||||
updateTile: function(tile) {
|
||||
this._loadTile(tile, tile.tilePoint, this._map.getZoom());
|
||||
if (tile) {
|
||||
tile.url = this.getTileUrlFromName(name, timestamp);
|
||||
this._loadQueue.push(tile);
|
||||
this._tickLoadQueue();
|
||||
}
|
||||
},
|
||||
|
||||
// Some helper functions.
|
||||
|
@ -695,7 +695,7 @@ DynMap.prototype = {
|
||||
|
||||
swtch(update.type, {
|
||||
tile: function() {
|
||||
me.onTileUpdated(update.name,update.timestamp);
|
||||
me.maptype.updateNamedTile(update.name, update.timestamp);
|
||||
},
|
||||
playerjoin: function() {
|
||||
$(me).trigger('playerjoin', [ update.playerName ]);
|
||||
@ -742,25 +742,6 @@ DynMap.prototype = {
|
||||
}
|
||||
return tile;
|
||||
},
|
||||
onTileUpdated: function(tileName,timestamp) {
|
||||
var me = this;
|
||||
var prev = this.registeredTiles[tileName];
|
||||
var a_b = true;
|
||||
if (prev && (prev.indexOf('upd=0') > 0))
|
||||
a_b = false;
|
||||
var url = me.options.url.tiles;
|
||||
if (a_b) {
|
||||
if (url.indexOf('?') > 0) {
|
||||
this.registeredTiles[tileName] = url + escape(me.world.name + '/' + tileName) + '&upd=0';
|
||||
}
|
||||
else {
|
||||
this.registeredTiles[tileName] = url + escape(me.world.name + '/' + tileName) + '?upd=0';
|
||||
}
|
||||
}
|
||||
else
|
||||
this.registeredTiles[tileName] = url + me.world.name + '/' + tileName;
|
||||
me.maptype.updateNamedTile(tileName);
|
||||
},
|
||||
addPlayer: function(update) {
|
||||
var me = this;
|
||||
var player = me.players[update.account] = {
|
||||
|
Loading…
Reference in New Issue
Block a user