coding standards for Grid.js

git-svn-id: http://svn.openlayers.org/trunk/openlayers@890 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-07-06 01:51:14 +00:00
parent 353c7b810d
commit f14a6049c1
+20 -7
View File
@@ -16,7 +16,7 @@ OpenLayers.Layer.Grid.prototype =
/** this is an array of rows, each row is an array of tiles /** this is an array of rows, each row is an array of tiles
* *
* @type Array(Array()) */ * @type Array(Array) */
grid: null, grid: null,
/** asserts whether or not the layer's images have an alpha channel /** asserts whether or not the layer's images have an alpha channel
@@ -64,8 +64,9 @@ OpenLayers.Layer.Grid.prototype =
* @param {OpenLayers.Size} size * @param {OpenLayers.Size} size
*/ */
setTileSize: function (size) { setTileSize: function (size) {
if (size) if (size) {
this.tileSize = size.copyOf(); this.tileSize = size.copyOf();
}
}, },
/** This function is called whenever the map is moved. All the moving /** This function is called whenever the map is moved. All the moving
@@ -108,8 +109,13 @@ OpenLayers.Layer.Grid.prototype =
* @type OpenLayers.Bounds * @type OpenLayers.Bounds
*/ */
getGridBounds:function() { getGridBounds:function() {
var topLeftTile = this.grid[0][0]; var topLeftTile = this.grid[0][0];
var bottomRightTile = this.grid[this.grid.length-1][this.grid[0].length-1];
var bottom = this.grid.length - 1;
var right = this.grid[0].length - 1;
var bottomRightTile = this.grid[bottom][right];
return new OpenLayers.Bounds(topLeftTile.bounds.left, return new OpenLayers.Bounds(topLeftTile.bounds.left,
bottomRightTile.bounds.bottom, bottomRightTile.bounds.bottom,
bottomRightTile.bounds.right, bottomRightTile.bounds.right,
@@ -160,16 +166,23 @@ OpenLayers.Layer.Grid.prototype =
this.grid.append(row); this.grid.append(row);
tileoffsetlon = startLon; tileoffsetlon = startLon;
tileoffsetx = startX; tileoffsetx = startX;
do { do {
var tileBounds = new OpenLayers.Bounds(tileoffsetlon, var tileBounds = new OpenLayers.Bounds(tileoffsetlon,
tileoffsetlat, tileoffsetlat,
tileoffsetlon + tilelon, tileoffsetlon + tilelon,
tileoffsetlat + tilelat); tileoffsetlat + tilelat);
var tile = this.addTile(tileBounds, var x = tileoffsetx;
new OpenLayers.Pixel(tileoffsetx - parseInt(this.map.layerContainerDiv.style.left), x -= parseInt(this.map.layerContainerDiv.style.left);
tileoffsety - parseInt(this.map.layerContainerDiv.style.top))
); var y = tileoffsety;
y -= parseInt(this.map.layerContainerDiv.style.top);
var px = new OpenLayers.Pixel(x, y);
var tile = this.addTile(tileBounds, px);
tile.draw(this.alpha); tile.draw(this.alpha);
row.append(tile); row.append(tile);