[ka-Map-users] Detecting when tile images have loaded

David Badke dbadke at uvic.ca
Thu Apr 20 17:44:32 EDT 2006


Pete:

Thanks for the info - I missed that discussion.

I'm not sure I understand Brent's idea, but wouldn't you have to keep a 
list of the IDs that were generated but not yet loaded? I suspect that 
the same problem would still be there anyway. The count of the number of 
times the tiler is called (in setTile) is always some fixed number 
higher (depends on the number of layers somehow) than the number of 
times onload is triggered - on my system, it is a difference of about 16 
or 17 per layer. But even compensating for that, and ignoring aPixel 
tiles and already visible tiles, the count hits zero before the images 
are all drawn. My tests seem to suggest that all of the onload events 
have fired before the browser has actually rendered everything - like 
they trigger when the browser receives the image (has it in its local 
cache?), not after the image is rendered. If so, this method will never 
work.

Frustrating...

David

Pete Giencke wrote:
> David,
>
> There was actually some discussion on this topic last year
> (http://lists.maptools.org/pipermail/ka-map-users/2005-October/000484.html).
> Through that discussion, I ran into the same luck you're having with this,
> which is, I wasn't able to (repeatably) detect when all the images had
> loaded. I think Brent Peterson was on the right track back when he suggested
> comparing the ids of the tiles loaded with the tiles generated. 
>
> -pete
>
>
> -----Original Message-----
> From: ka-map-users-bounces at lists.maptools.org
> [mailto:ka-map-users-bounces at lists.maptools.org] On Behalf Of David Badke
> Sent: Thursday, April 20, 2006 2:17 PM
> To: ka-map-users at lists.maptools.org
> Subject: [ka-Map-users] Detecting when tile images have loaded
>
> I would like to be able to detect when all of the tile images have been
> loaded - that is, get an event to trigger when the map image (or only a
> certain layer) has been fully drawn by the browser. Since there is no such
> event in ka-Map now, I have been trying to create one, with very limited
> success. I had thought I could count the number of calls to tile.php (which
> I can, in kaMap.setTile) to get a count of the number of images expected,
> then decrement the count in the tile image onload event hander
> (kaMap_imgOnLoad) as each image loads. This doesn't work; even when I
> compensate for kaMap_imgOnLoad being called for already visible tiles, the
> count hits zero when the browser has only partly finished drawing. I have
> not found any reliable way to detect when all tiles are loaded, so
> triggering an event (which in itself is easy to do with the event manager)
> is problematic - when do I trigger it?
>
> Anyone have any ideas how this could be done?
>
> David
>
>   


-- 

David Badke
Humanities Computing and Media Center
University of Victoria, BC, Canada



More information about the ka-Map-users mailing list