From 57764813e3c6714add482cf22ef2263483c76137 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 20 Jun 2012 23:37:35 +0200 Subject: [PATCH] Constructing tiles with bounds. --- src/ol/layer/XYZ.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ol/layer/XYZ.js b/src/ol/layer/XYZ.js index ed65225ffa..6c1fbac17d 100644 --- a/src/ol/layer/XYZ.js +++ b/src/ol/layer/XYZ.js @@ -144,20 +144,19 @@ ol.layer.XYZ.prototype.getData = function(bounds, resolution) { var tiles = [], tile, url, - x = 0, - y = 0; - while (gridTop - (y * tileHeightGeo) > boundsMinY) { + tileBottom, tileRight, tileBounds; + for (var y=0, tileTop=gridTop; tileTop > boundsMinY; ++y, tileTop-=tileHeightGeo) { tiles[y] = []; - while (gridLeft + (x * tileWidthGeo) < boundsMaxX) { + tileBottom = tileTop - tileHeightGeo; + for (var x=0, tileLeft=gridLeft; tileLeft < boundsMaxX; ++x, tileLeft+=tileWidthGeo) { + tileRight = tileLeft + tileWidthGeo; + tileBounds = new ol.Bounds(tileLeft, tileBottom, tileRight, tileTop, this.projection_); url = me.url_.replace('{x}', offsetX + x + '') .replace('{y}', offsetY + y + '') .replace('{z}', zoom); - tile = new ol.Tile(url); + tile = new ol.Tile(url, tileBounds); tiles[y][x] = tile; - x++; } - y++; - x = 0; } return new ol.TileSet(tiles, tileWidth, tileHeight, resolution);