Add context argument to Tile.getImage to support re-use in DOM renderer
This commit is contained in:
+23
-2
@@ -56,6 +56,12 @@ ol.Tile = function(tileCoord, src, opt_crossOrigin) {
|
|||||||
this.image_.crossOrigin = opt_crossOrigin;
|
this.image_.crossOrigin = opt_crossOrigin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Object.<number, Image>}
|
||||||
|
*/
|
||||||
|
this.imageByContext_ = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Array.<number>}
|
* @type {Array.<number>}
|
||||||
@@ -75,10 +81,25 @@ ol.Tile.prototype.dispatchChangeEvent = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param {Object=} opt_context Object.
|
||||||
* @return {Image} Image.
|
* @return {Image} Image.
|
||||||
*/
|
*/
|
||||||
ol.Tile.prototype.getImage = function() {
|
ol.Tile.prototype.getImage = function(opt_context) {
|
||||||
return this.image_;
|
if (goog.isDef(opt_context)) {
|
||||||
|
var image;
|
||||||
|
var key = goog.getUid(opt_context);
|
||||||
|
if (key in this.imageByContext_) {
|
||||||
|
return this.imageByContext_[key];
|
||||||
|
} else if (goog.object.isEmpty(this.imageByContext_)) {
|
||||||
|
image = this.image_;
|
||||||
|
} else {
|
||||||
|
image = /** @type {Image} */ this.image_.cloneNode(false);
|
||||||
|
}
|
||||||
|
this.imageByContext_[key] = image;
|
||||||
|
return image;
|
||||||
|
} else {
|
||||||
|
return this.image_;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user