[OpenLayers-Dev] safari bug on window resize
Paul Spencer
pspencer at dmsolutions.ca
Tue Oct 30 16:45:56 EDT 2007
Devs,
there seems to be a bug in Safari 3 (not sure about 2) with trunk
where a window resize causes the tiles to disappear. Zak and I
tracked this down to the fact that Safari does not trigger an onload
event on the image when you set the .src of the image and it is not
different from the current src.
Our fix was this patch:
Index: /ms4w/apps/openlayers/trunk/openlayers/lib/OpenLayers/Tile/
Image.js
===================================================================
--- /ms4w/apps/openlayers/trunk/openlayers/lib/OpenLayers/Tile/
Image.js (revision 5069)
+++ /ms4w/apps/openlayers/trunk/openlayers/lib/OpenLayers/Tile/
Image.js (working copy)
@@ -119,6 +119,7 @@
OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
null, null, imageSize, this.url);
} else {
+ this.imgDiv.src = '';
this.imgDiv.src = this.url;
OpenLayers.Util.modifyDOMElement(this.imgDiv,
null, null, imageSize) ;
By assigning an empty string, this causes Safari to behave properly
when you assign the real source.
An alternate patch would be to set the imgDiv.src = '' in the clear
function.
An alternate patch would be to check if the urls are identical (not
sure if checking == is sufficient or if the isEquivalent function
should be used) and just show the imgDiv if they are the same:
But all this leads me to question what is happening if we are setting
the source to the same image?
It appears that a window resize is causing the map to redraw as if
the zoom level has changed. This causes all the tiles to get
cleared. I don't understand why this is necessary. There is code in
setCenter to just move the layer container if the zoom hasn't changed
and this seems like a reasonable thing, so why is updateSize forcing
the zoom to change?
I am willing to put together a patch if I can get some feedback on
what the right solution would be:
1. clear src just before setting it
2. clear src in the clear function when we hide the imgDiv
3. only set the src if the new url is different from the old url,
otherwise just show the imgDiv again
4. change updateSize in Map to not force a zoom level change
Cheers
Paul
+-----------------------------------------------------------------+
|Paul Spencer pspencer at dmsolutions.ca |
+-----------------------------------------------------------------+
|Chief Technology Officer |
|DM Solutions Group Inc http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+
More information about the Dev
mailing list