[ka-Map-users] img.onload bug within IE?

Wagner, Jeffrey S. (Mission Systems) j.wagner at ngc.com
Tue Jan 23 20:03:56 EST 2007


Actually, the issue has to do with IE caching images.  You need to move
the onload handler before setting the source:
 
this.img = new Image();
var timg = this.img;
var tw = this.icon_w;
var th = this.icon_h;
this.img.onload = function() {
        ctx.drawImage(timg, dx, dy, tw, th);
        ctx.restore();
}
this.img.src = this.icon_src;
 
-----Original Message-----
Hi Pg,
    I was wondering if you are aware of icons not getting drawn with 
kaXmlOverlay. This only happens within Internet Explorer and the problem

is intermittent. Sometimes, while trying to draw many icons (20-50 or 
even 100), not all of them appeared. Apparently, if we look at the 
"kaXmlIcon.prototype.draw_canvas" function, there is this line where you

specify an "img.onload" event. I did some tests and found that this 
event is not always being triggered which is why the "ctx.drawImage" 
function does not always get called. My website runs over https.
 
Changing this:
this.img.onload = function() {
        ctx.drawImage(timg, dx, dy, tw, th);
        ctx.restore();
}
to this:
        ctx.drawImage(timg, dx, dy, tw, th);
        ctx.restore();
 
seems to make it work fine now.
 
Cheers,
Wayne

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/ka-map-users/attachments/20070123/4091b698/attachment.html


More information about the ka-Map-users mailing list