Fixing KaMap layer
This also fixes an issue that has gone unnoticed for a while: the grid did not cover the bottom of the map viewport, but instead covered an invisible area above the top of the map viewport.
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, tileoffsetlat,
|
||||
* tileoffsetlat, tileoffsetx, tileoffsety
|
||||
* {Object} Object containing properties tilelon, tilelat, tileoffsetx,
|
||||
* tileoffsety, startcol, startrow
|
||||
*/
|
||||
calculateGridLayout: function(bounds, origin, resolution) {
|
||||
var tilelon = resolution*this.tileSize.w;
|
||||
@@ -103,22 +103,42 @@ OpenLayers.Layer.KaMap = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
var tilecol = Math.floor(offsetlon/tilelon) - this.buffer;
|
||||
var tilecolremain = offsetlon/tilelon - tilecol;
|
||||
var tileoffsetx = -tilecolremain * this.tileSize.w;
|
||||
var tileoffsetlon = tilecol * tilelon;
|
||||
|
||||
var offsetlat = bounds.top;
|
||||
var tilerow = Math.ceil(offsetlat/tilelat) + this.buffer;
|
||||
var tilerow = Math.floor(offsetlat/tilelat) + this.buffer;
|
||||
var tilerowremain = tilerow - offsetlat/tilelat;
|
||||
var tileoffsety = -(tilerowremain+1) * this.tileSize.h;
|
||||
var tileoffsetlat = tilerow * tilelat;
|
||||
|
||||
return {
|
||||
tilelon: tilelon, tilelat: tilelat,
|
||||
tileoffsetlon: tileoffsetlon, tileoffsetlat: tileoffsetlat,
|
||||
tileoffsetx: tileoffsetx, tileoffsety: tileoffsety,
|
||||
startcol: tilecol, startrow: tilerow
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getTileBoundsForGridIndex
|
||||
*
|
||||
* Parameters:
|
||||
* row - {Number} The row of the grid
|
||||
* col - {Number} The column of the grid
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Bounds>} The bounds for the tile at (row, col)
|
||||
*/
|
||||
getTileBoundsForGridIndex: function(row, col) {
|
||||
var origin = this.getTileOrigin();
|
||||
var tileLayout = this.gridLayout;
|
||||
var tilelon = tileLayout.tilelon;
|
||||
var tilelat = tileLayout.tilelat;
|
||||
var minX = (tileLayout.startcol + col) * tilelon;
|
||||
var minY = (tileLayout.startrow - row) * tilelat;
|
||||
return new OpenLayers.Bounds(
|
||||
minX, minY,
|
||||
minX + tilelon, minY + tilelat
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: clone
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user