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:
@@ -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
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user