[Mapserver-users] pan/javascript

Kaps Stefan 0098kast at edu.fh-kaernten.ac.at
Mon Apr 19 15:58:04 PDT 2004


hello,
i wanted to create a pan control as it is described in the tutorial. so i did the javascript part and the part with the arrows.
 
<script language="javascript">
  var pansize = 0.80;
  function pan(direction) {
    var x, y;
    if(direction == 'n') {
       x = ([mapwidth]-1)/2.0;
       y = 0 - [mapheight]*pansize + [mapheight]/2.0;
     } else if(direction == 'nw') {
       x = 0 - [mapwidth]*pansize + [mapwidth]/2.0;
       y = 0 - [mapheight]*pansize + [mapheight]/2.0;
     } else if(direction == 'ne') {
       x = ([mapwidth]-1) + [mapwidth]*pansize - [mapwidth]/2.0;
       y = 0 - [mapheight]*pansize + [mapheight]/2.0;
     } else if(direction == 's') {
       x = ([mapwidth]-1)/2.0;
       y = ([mapheight]-1) + [mapheight]*pansize - [mapheight]/2.0;
     } else if(direction == 'sw') {
       x = 0 - [mapwidth]*pansize + [mapwidth]/2.0;
       y = ([mapheight]-1) + [mapheight]*pansize - [mapheight]/2.0;
     } else if(direction == 'se') {
       x = ([mapwidth]-1) + [mapwidth]*pansize - [mapwidth]/2.0;
       y = ([mapheight]-1) + [mapheight]*pansize - [mapheight]/2.0;
     } else if(direction == 'e') {
       x = ([mapwidth]-1) + [mapwidth]*pansize - [mapwidth]/2.0;
       y = ([mapheight]-1)/2.0;
     } else if(direction == 'w') {
       x = 0 - [mapwidth]*pansize + [mapwidth]/2.0;
       y = ([mapheight]-1)/2.0;
     }

    document.mapserv.zoom[0].selected = true;
    document.mapserv.imgxy.value = x + " " + y;
    document.mapserv.submit();
  }
 </script>
...
<td>align="right" bordercolor="#ECE9D8" bgcolor="#666666"><a href="javascript:pan('nw')"><img src="/graphics/nw.gif" width="18" height="18" border="0" alt="pan northwest"></a></td>
...
 
thats all i did but it doesn't work... does anybody know what i've done wrong or what i have forgotten?!
 
cheers,
Stefan





More information about the MapServer-users mailing list