[ka-Map-users] ka-Map map file list bug

David Badke dbadke at uvic.ca
Thu Jan 19 12:22:39 EST 2006


In the CVS version of ka-Map the "select a map" list (the SELECT tag) 
does not get populated with a list of the maps defined in config.php 
($aszMapFiles array). This array is copied into the aMaps array in the 
addmap function, with the statement

this.aMaps[oMap.name] = oMap;  [line 1548]

which creates a JavaScript associative array object element because 
oMap.name is a string. Later, in the myInitialized() function 
(startUp.js), the aMaps array is loaded into the OPTION tags for the 
SELECT list (around line 86):

    for(var i=0; i < aMaps.length; i++) {
     oSelect[j++] = new Option(aMaps[i].title,aMaps[i].name,false,false);
    }
 
However, since the aMaps array was loaded as an associative array, 
aMaps.length is always zero (which is imo is rather odd, but it is true 
at least in Firefox and IE), so the loop never executes. The loop should 
be coded as:

    for(var i in aMaps) {
     oSelect[j++] = new Option(aMaps[i].title,aMaps[i].name,false,false);
    }

This loops through every element in aMaps, without needing the length, 
and the map list is loaded properly.

David



More information about the ka-Map-users mailing list