Skip to content

Commit c834328

Browse files
committed
Refactored functions
1 parent aea6a9a commit c834328

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
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: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ OpenLayers.Control.ExportMap = OpenLayers.Class(OpenLayers.Control, {
1212
type: OpenLayers.Control.TYPE_BUTTON,
1313
canvasComponents: [],
1414
tileData: {},
15+
/**
16+
* Remove all the Canvas Components and the Tile Data
17+
*/
18+
removeStoredData: function () {
19+
this.canvasComponents = [];
20+
this.tileData = {};
21+
},
1522
/**
1623
* A function to trigger the ExportMap functions.
1724
*
@@ -23,8 +30,7 @@ OpenLayers.Control.ExportMap = OpenLayers.Class(OpenLayers.Control, {
2330

2431
this.setUpCanvas(canvas);
2532

26-
this.canvasComponents = [];
27-
this.tileData = {};
33+
this.removeStoredData();
2834

2935
this.map.layers.forEach(function (layer) {
3036
if (layer.visibility) {
@@ -102,8 +108,8 @@ OpenLayers.Control.ExportMap = OpenLayers.Class(OpenLayers.Control, {
102108

103109
var that = this;
104110
this.imagePromises = [];
105-
layer.grid.forEach(function (grid) {
106-
grid.forEach(function (tile) {
111+
layer.grid.forEach(function (tiles) {
112+
tiles.forEach(function (tile) {
107113
var url = layer.getURL(tile.bounds);
108114

109115
if (!that.tileData[url]) {
@@ -118,7 +124,7 @@ OpenLayers.Control.ExportMap = OpenLayers.Class(OpenLayers.Control, {
118124
});
119125

120126
Promise.all(this.imagePromises)
121-
.then(function(){
127+
.then(function () {
122128
that.drawLoadedImages()
123129
});
124130
},

0 commit comments

Comments
 (0)