From ac60e4fcf69978c94f1190be67a64ec719d00aad Mon Sep 17 00:00:00 2001 From: bartvde Date: Tue, 23 Feb 2010 17:16:49 +0000 Subject: [PATCH] load events not working properly in OpenLayers.Tile.Image.IFrame, r=fvanderbiest (closes #2406) git-svn-id: http://svn.openlayers.org/trunk/openlayers@10082 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Tile/Image/IFrame.js | 32 +++++++++++++++-------------- tests/Tile/Image/IFrame.html | 3 ++- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/OpenLayers/Tile/Image/IFrame.js b/lib/OpenLayers/Tile/Image/IFrame.js index 46f934500d..9419167245 100644 --- a/lib/OpenLayers/Tile/Image/IFrame.js +++ b/lib/OpenLayers/Tile/Image/IFrame.js @@ -122,21 +122,6 @@ OpenLayers.Tile.Image.IFrame = OpenLayers.Class(OpenLayers.Tile.Image, { // we need this reference to check back the viewRequestID this.imgDiv.map = this.layer.map; - - //bind a listener to the onload of the iframe so that we - // can register when a tile has finished loading. - var onload = function() { - this.show(); - //normally isLoading should always be true here but there are some - // right funky conditions where loading and then reloading a tile - // with the same url *really*fast*. this check prevents sending - // a 'loadend' if the msg has already been sent - // - if (this.isLoading) { - this.isLoading = false; - this.events.triggerEvent("loadend"); - } - }; }, /** @@ -206,6 +191,23 @@ OpenLayers.Tile.Image.IFrame = OpenLayers.Class(OpenLayers.Tile.Image, { OpenLayers.Util.modifyDOMElement(iframe, id, new OpenLayers.Pixel(0,0), this.layer.getImageSize(), "absolute"); + //bind a listener to the onload of the iframe so that we + // can register when a tile has finished loading. + var onload = function() { + this.show(); + //normally isLoading should always be true here but there are some + // right funky conditions where loading and then reloading a tile + // with the same url *really*fast*. this check prevents sending + // a 'loadend' if the msg has already been sent + // + if (this.isLoading) { + this.isLoading = false; + this.events.triggerEvent("loadend"); + } + }; + OpenLayers.Event.observe(iframe, 'load', + OpenLayers.Function.bind(onload, this)); + return iframe; }, diff --git a/tests/Tile/Image/IFrame.html b/tests/Tile/Image/IFrame.html index f8f8e4aa78..5a3da99354 100644 --- a/tests/Tile/Image/IFrame.html +++ b/tests/Tile/Image/IFrame.html @@ -106,7 +106,8 @@ layer = new OpenLayers.Layer.WMS.Post(name, wmsUrl, {layers: 'basic'}); map.addLayer(layer); var tile = new OpenLayers.Tile.Image.IFrame(layer, position, bounds, url, size); - var imgDiv = tile.createImgDiv(); + tile.renderTile(); + var imgDiv = tile.imgDiv; var iFrame = imgDiv.firstChild; var eventPane = imgDiv.childNodes[1];