[ka-Map-users] Positional parameters in startUp.js and kaMap.js

David Badke dbadke at uvic.ca
Thu Feb 2 13:00:38 EST 2006

I have been trying to pass an additional parameter to init.php on the 
URL - that is, additional to map=xxx, extents=xxx, centerPoint=xxx. I 
was puzzled as to why the additional parameter never made it to init.php 
until I examined how startUp.js and kaMpa.js handle the parameters, and 
was dismayed to find that the URL parameters, despite being of the 
name=value type, are being treated as positional. That is, 
kaMap.initialize() assumes that its first parameter is 'map', the second 
is 'extents', and the third is 'centerPoint', with no possibility of any 
more parameters. startUp.js also assumes the parameters are positional 
('map' followed by 'extents' followed by 'centerPoint'), and feeds the 
URL parameters to kaMap.initialize() in that order. kaMap.initialize() 
ignores any additional parameters.

This is a Bad Thing (IMO).

Positional parameters on a URL are not a good idea. The whole concept of 
name=value parameters is that order of presentation doesn't matter, and 
any parameter can be omitted. As it is, a URL like 
'kamap/index.html?extents=0,0,100,100&map=mymap' will not work; 'map=' 
has to come first.

Any and all parameters found on the URL (after the ?) should be passed 
along to init.php as-is; neither startUp.js nor kaMap.initialize() uses 
them directly, so should not be parsing them. Only init.php needs to 
parse them.

So instead of this code in startUp.js (myOnLoad() function), which 
assumes a specific parameter order:

  if (szURL.indexOf("?") != -1) {
      myMap= (myParams[0])? 
myParams[0].slice(1+myParams[0].indexOf("=")) : '';
      myExtents= (myParams[1])? 
myParams[1].slice(1+myParams[1].indexOf("=")): '';
      myCenterPoint= (myParams[2])? 
myParams[2].slice(1+myParams[2].indexOf("=")): '';
      myMapList = (myParams[3])? 
myParams[3].slice(1+myParams[3].indexOf("=")): '';
  } else {

it should be:

  if (szURL.indexOf("?") != -1) {
  } else {

and kaMap.initialize() should change from:

    if (arguments.length > 0 && arguments[0] != '')
        szURL = szURL + sep + "map="+ arguments[0];
        sep = "&";
    if (arguments.length > 1 && arguments[1] != '')
        szURL = szURL + sep + "extents="+ arguments[1];
        sep = "&";
    if (arguments.length > 2 && arguments[2] != '')
        szURL = szURL + sep + "centerPoint="+ arguments[2];
        sep = "&";


    if (arguments.length > 0 && arguments[0] != '')
       szURL = szURL + sep + arguments[0];

If kaMap.initialize() needs to be called with internally-generated 
parameters (ie: not from a URL), the name=value style parameters can be 
generated and it can be called like:


so there is no reason for kaMap.initialize() to be working with 
positional parameters at all.

Just my opinion, but I have to modify the code this way for my project 
to work. Perhaps there is a better way that does not require me to 
modify kaMap.js - if so, I would be glad to hear of it.


More information about the ka-Map-users mailing list