diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index a56791ded1..5d90e0ec0d 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -36,6 +36,13 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { */ frame: null, + + /** + * Property: layerAlphaHack + * {Boolean} True if the png alpha hack needs to be applied on the layer's div. + */ + layerAlphaHack: null, + /** TBD 3.0 - reorder the parameters to the init function to remove * URL. the getUrl() function on the layer gets called on * each draw(), so no need to specify it here. @@ -58,6 +65,8 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { this.frame = document.createElement('div'); this.frame.style.overflow = 'hidden'; this.frame.style.position = 'absolute'; + + this.layerAlphaHack = this.layer.alpha && OpenLayers.Util.alphaHack(); }, /** @@ -115,7 +124,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { null, this.position, this.size); var imageSize = this.layer.getImageSize(); - if (this.layer.alpha) { + if (this.layerAlphaHack) { OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv, null, null, imageSize, this.url); } else { @@ -146,7 +155,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { var offset = this.layer.imageOffset; var size = this.layer.getImageSize(); - if (this.layer.alpha) { + if (this.layerAlphaHack) { this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null, offset, size, @@ -230,7 +239,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { // Sometimes our image will load after it has already been removed // from the map, in which case this check is not needed. if (this.layer) { - var loaded = this.layer.alpha ? this.imgDiv.firstChild.src : this.imgDiv.src; + var loaded = this.layerAlphaHack ? this.imgDiv.firstChild.src : this.imgDiv.src; if (!OpenLayers.Util.isEquivalentUrl(loaded, this.url)) { this.imgDiv.style.display = "none"; }