[ka-Map-users] Memory leaks in kaXmlOverlay?
Øyvind Hanssen
oyvind at cs.uit.no
Wed May 24 13:13:07 EDT 2006
I started KaXmlOverlay the following way:
var myCoordinates = myMovingOverlay = myInterval = null;
function localOnLoad()
{
...
myKaMap.registerForEvent( KAMAP_MAP_INITIALIZED, null, localMapInitialized );
...
}
function localMapInitialized( eventID, mapName ) {
myMovingOverlay = new kaXmlOverlay( myKaMap, 250 );
myMovingOverlay.loadXml('XMLDATAURL');
myInterval = setInterval("myMovingOverlay.loadXml('XMLDATAURL')", 20000);
}
If you use multiple mapfiles, a new overlay is created each time the user
switches between mapfiles. This leads to problems of course. So, I just add
a test if an overlay already exists:
function localMapInitialized( eventID, mapName ) {
if (myMovingOverlay == null) {
myMovingOverlay = new kaXmlOverlay( myKaMap, 250 );
...
}
...
}
Alternatively, one can remove the existing one before creating a new.
Regards
Øyvind
More information about the ka-Map-users
mailing list