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:
@@ -16,7 +16,7 @@ OpenLayers.Layer.Grid.prototype =
|
||||
|
||||
/** this is an array of rows, each row is an array of tiles
|
||||
*
|
||||
* @type Array(Array()) */
|
||||
* @type Array(Array) */
|
||||
grid: null,
|
||||
|
||||
/** asserts whether or not the layer's images have an alpha channel
|
||||
@@ -64,8 +64,9 @@ OpenLayers.Layer.Grid.prototype =
|
||||
* @param {OpenLayers.Size} size
|
||||
*/
|
||||
setTileSize: function (size) {
|
||||
if (size)
|
||||
if (size) {
|
||||
this.tileSize = size.copyOf();
|
||||
}
|
||||
},
|
||||
|
||||
/** This function is called whenever the map is moved. All the moving
|
||||
@@ -108,8 +109,13 @@ OpenLayers.Layer.Grid.prototype =
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
getGridBounds:function() {
|
||||
|
||||
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,
|
||||
bottomRightTile.bounds.bottom,
|
||||
bottomRightTile.bounds.right,
|
||||
@@ -132,8 +138,8 @@ OpenLayers.Layer.Grid.prototype =
|
||||
var bounds = this.map.getExtent();
|
||||
var extent = this.map.getMaxExtent();
|
||||
var resolution = this.map.getResolution();
|
||||
var tilelon = resolution*this.tileSize.w;
|
||||
var tilelat = resolution*this.tileSize.h;
|
||||
var tilelon = resolution * this.tileSize.w;
|
||||
var tilelat = resolution * this.tileSize.h;
|
||||
|
||||
var offsetlon = bounds.left - extent.left;
|
||||
var tilecol = Math.floor(offsetlon/tilelon);
|
||||
@@ -150,7 +156,7 @@ OpenLayers.Layer.Grid.prototype =
|
||||
tileoffsetx = Math.round(tileoffsetx); // heaven help us
|
||||
tileoffsety = Math.round(tileoffsety);
|
||||
|
||||
this.origin = new OpenLayers.Pixel(tileoffsetx,tileoffsety);
|
||||
this.origin = new OpenLayers.Pixel(tileoffsetx, tileoffsety);
|
||||
|
||||
var startX = tileoffsetx;
|
||||
var startLon = tileoffsetlon;
|
||||
@@ -160,16 +166,23 @@ OpenLayers.Layer.Grid.prototype =
|
||||
this.grid.append(row);
|
||||
tileoffsetlon = startLon;
|
||||
tileoffsetx = startX;
|
||||
|
||||
do {
|
||||
var tileBounds = new OpenLayers.Bounds(tileoffsetlon,
|
||||
tileoffsetlat,
|
||||
tileoffsetlon+tilelon,
|
||||
tileoffsetlat+tilelat);
|
||||
tileoffsetlat,
|
||||
tileoffsetlon + tilelon,
|
||||
tileoffsetlat + tilelat);
|
||||
|
||||
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 = this.addTile(tileBounds, px);
|
||||
|
||||
var tile = this.addTile(tileBounds,
|
||||
new OpenLayers.Pixel(tileoffsetx - parseInt(this.map.layerContainerDiv.style.left),
|
||||
tileoffsety - parseInt(this.map.layerContainerDiv.style.top))
|
||||
);
|
||||
tile.draw(this.alpha);
|
||||
row.append(tile);
|
||||
|
||||
@@ -278,7 +291,7 @@ OpenLayers.Layer.Grid.prototype =
|
||||
* @returns The added OpenLayers.Tile
|
||||
* @type OpenLayers.Tile
|
||||
*/
|
||||
addTile:function(bounds,position) {
|
||||
addTile:function(bounds, position) {
|
||||
// Should be implemented by subclasses
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user