From 7a3f9b8444b8148e6e015121b19f7491cfa12da5 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Wed, 9 Aug 2006 13:38:59 +0000 Subject: [PATCH] KaMap uses a different initTiles because it doesn't use the same starting point for '0,0'. This meant that with the new initTiles change, we were not adding enough buffer tiles around the kamap layers, so they would display funkily. This fixes that issue. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1156 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/KaMap.js | 55 ++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/lib/OpenLayers/Layer/KaMap.js b/lib/OpenLayers/Layer/KaMap.js index 9b7f14ebce..c2f65c9b37 100644 --- a/lib/OpenLayers/Layer/KaMap.js +++ b/lib/OpenLayers/Layer/KaMap.js @@ -77,13 +77,6 @@ OpenLayers.Layer.KaMap.prototype = _initTiles:function() { - //first of all, clear out the main div - this.div.innerHTML = ""; - - //now clear out the old grid and start a new one - this.clearGrid(); - this.grid = new Array(); - var viewSize = this.map.getSize(); var bounds = this.map.getExtent(); var extent = this.map.getMaxExtent(); @@ -111,31 +104,53 @@ OpenLayers.Layer.KaMap.prototype = var startX = tileoffsetx; var startLon = tileoffsetlon; + var rowidx = 0; + do { - var row = new Array(); - this.grid.push(row); + var row; + + row = this.grid[rowidx++]; + if (!row) { + row = new Array(); + this.grid.push(row); + } + tileoffsetlon = startLon; tileoffsetx = startX; + + var colidx = 0; + do { var tileBounds = new OpenLayers.Bounds(tileoffsetlon, - tileoffsetlat, - tileoffsetlon+tilelon, - tileoffsetlat+tilelat); + tileoffsetlat, + tileoffsetlon + tilelon, + tileoffsetlat + tilelat); - var tile = this.addTile(tileBounds, - new OpenLayers.Pixel(tileoffsetx - parseInt(this.map.layerContainerDiv.style.left), - tileoffsety - parseInt(this.map.layerContainerDiv.style.top)) - ); - tile.draw(); - row.push(tile); + var x = tileoffsetx; + x -= parseInt(this.map.layerContainerDiv.style.left); + + var y = tileoffsety; + y -= parseInt(this.map.layerContainerDiv.style.top); + + var px = new OpenLayers.Pixel(x, y); + var tile; + + tile = row[colidx++]; + if (!tile) { + tile = this.addTile(tileBounds, px); + tile.draw(); + row.push(tile); + } else { + tile.moveTo(tileBounds, px); + } tileoffsetlon += tilelon; tileoffsetx += this.tileSize.w; - } while (tileoffsetlon < bounds.right) + } while (tileoffsetlon <= bounds.right + tilelon * this.buffer) tileoffsetlat -= tilelat; tileoffsety += this.tileSize.h; - } while(tileoffsetlat > bounds.bottom - tilelat) + } while(tileoffsetlat >= bounds.bottom - tilelat * this.buffer) },