Skip to content

Commit 5593066

Browse files
committed
refactored js
1 parent 80727e9 commit 5593066

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

build/ExportMap.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ExportMap.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,22 @@ OpenLayers.Control.ExportMap = OpenLayers.Class(OpenLayers.Control, {
110110
* @returns {undefined}
111111
*/
112112
stitchTiles: function (layer) {
113-
for (var gridIndex in layer.grid) {
114-
var grid = layer.grid[gridIndex];
115-
for (var tileIndex in grid) {
116-
var tile = grid[tileIndex];
113+
114+
var that = this;
115+
layer.grid.forEach(function (grid) {
116+
grid.forEach(function (tile) {
117117
var url = layer.getURL(tile.bounds);
118-
var tileXPosition = tile.position.x + this.offsetX;
119-
var tileYPosition = tile.position.y + this.offsetY;
120118

121-
if (this.tileData[url] === undefined) {
122-
this.tileData[url] = {x: tileXPosition, y: tileYPosition};
119+
if (!that.tileData[url]) {
120+
that.tileData[url] = {
121+
x: tile.position.x + that.offsetX,
122+
y: tile.position.y + that.offsetY
123+
};
123124
}
124125

125-
this.loadImage(url);
126-
}
127-
}
126+
that.loadImage(url);
127+
})
128+
});
128129
},
129130
/**
130131
* A function to load the tile image from a URL. When all the images have been loaded
@@ -162,8 +163,8 @@ OpenLayers.Control.ExportMap = OpenLayers.Class(OpenLayers.Control, {
162163
*
163164
* @private
164165
* @param {Canvas|Image} canvasComponent The Canvas or tile image being loaded on to the canvas
165-
* @param {integer} x The X coordinate of the image
166-
* @param {integer} y The Y coordinate of the image
166+
* @param {Number} x The X coordinate of the image
167+
* @param {Number} y The Y coordinate of the image
167168
* @returns {undefined}
168169
*/
169170
drawCanvasComponent: function (canvasComponent, x, y) {

0 commit comments

Comments
 (0)