Skip to content

Commit aea6a9a

Browse files
committed
Moved the promise in loadImage #4
1 parent d5c6b75 commit aea6a9a

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
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: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ OpenLayers.Control.ExportMap = OpenLayers.Class(OpenLayers.Control, {
113113
};
114114
}
115115

116-
that.imagePromises.push(
117-
new Promise(function (resolve, reject) {
118-
that.loadImage(resolve, url)
119-
}));
116+
that.imagePromises.push(that.loadImage(url));
120117
})
121118
});
122119

@@ -130,21 +127,23 @@ OpenLayers.Control.ExportMap = OpenLayers.Class(OpenLayers.Control, {
130127
* it will proceed to draw the images on the canvas using the drawCanvasComponent function
131128
*
132129
* @private
133-
* @param {} resolve
134130
* @param {String} url
135-
* @returns {undefined}
131+
* @returns {Promise}
136132
*/
137-
loadImage: function (resolve, url) {
138-
var image = document.createElement('img');
133+
loadImage: function (url) {
139134
var that = this;
135+
return new Promise(function (resolve, reject) {
136+
var image = document.createElement('img');
137+
var that2 = that;
140138

141-
image.onload = function () {
142-
// Add the tile to the front of the array
143-
that.canvasComponents.unshift(this);
144-
resolve(image);
145-
};
139+
image.onload = function () {
140+
// Add the tile to the front of the array
141+
that2.canvasComponents.unshift(image);
142+
resolve(image);
143+
};
146144

147-
image.src = url;
145+
image.src = url;
146+
});
148147
},
149148
/**
150149
* Draw the loaded images

0 commit comments

Comments
 (0)