Don't reuse tile images unless we have a new url to load.
Without this change, some browsers don't cache the images. See #454 for a discussion about this issue.
This commit is contained in:
@@ -339,9 +339,9 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
*/
|
||||
setImgSrc: function(url) {
|
||||
var img = this.imgDiv;
|
||||
img.style.visibility = 'hidden';
|
||||
img.style.opacity = 0;
|
||||
if (url) {
|
||||
img.style.visibility = 'hidden';
|
||||
img.style.opacity = 0;
|
||||
// don't set crossOrigin if the url is a data URL
|
||||
if (this.crossOriginKeyword) {
|
||||
if (url.substr(0, 5) !== 'data:') {
|
||||
@@ -351,6 +351,13 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
}
|
||||
}
|
||||
img.src = url;
|
||||
} else {
|
||||
// Remove reference to the image, and leave it to the browser's
|
||||
// caching and garbage collection.
|
||||
this.imgDiv = null;
|
||||
if (img.parentNode) {
|
||||
img.parentNode.removeChild(img);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user