Optimizing positions for rendering

Calculating pixel positions from origin and grid index causes alignment
issues in the grid. By going back to incremental positioning, we get a
result without blank spaces between tiles again.
This commit is contained in:
ahocevar
2012-10-12 03:23:56 +02:00
parent 66455600c7
commit ff4a1b2468
3 changed files with 22 additions and 45 deletions

View File

@@ -92,8 +92,8 @@ OpenLayers.Layer.KaMap = OpenLayers.Class(OpenLayers.Layer.Grid, {
* resolution - {Number}
*
* Returns:
* {Object} Object containing properties tilelon, tilelat, tileoffsetx,
* tileoffsety, startcol, startrow
* {Object} Object containing properties tilelon, tilelat, startcol,
* startrow
*/
calculateGridLayout: function(bounds, origin, resolution) {
var tilelon = resolution*this.tileSize.w;
@@ -101,17 +101,12 @@ OpenLayers.Layer.KaMap = OpenLayers.Class(OpenLayers.Layer.Grid, {
var offsetlon = bounds.left;
var tilecol = Math.floor(offsetlon/tilelon) - this.buffer;
var tilecolremain = offsetlon/tilelon - tilecol;
var tileoffsetx = -tilecolremain * this.tileSize.w;
var offsetlat = bounds.top;
var tilerow = Math.floor(offsetlat/tilelat) + this.buffer;
var tilerowremain = tilerow - offsetlat/tilelat;
var tileoffsety = -(tilerowremain+1) * this.tileSize.h;
return {
tilelon: tilelon, tilelat: tilelat,
tileoffsetx: tileoffsetx, tileoffsety: tileoffsety,
startcol: tilecol, startrow: tilerow
};
},