zooming and panning with dbox

maurosa at iol.it maurosa at IOL.IT
Mon Dec 17 07:26:36 EST 2007


Hi list.

I am  trying to use ms4w-dbox 0.9a1 to draw a rectangle and to pan an image.
Since my mapserver instance cannot be controlled by the client (it is hidden server side), the client should just return the pixel rectangle drawn by the user while zooming, and somehow the “shift” meant by a dragging action.
I found a way of doing it for zoom operations, but not for drag ones.
I just need  to understand from where to where the user dragged the image in pixel coordinates.

This is my very simple example:

<script language="JavaScript" src="wz_jsgraphics.js"></script>
<script language="JavaScript" src="x_dhtml.js"></script>
<script language="JavaScript" src="dbox.js"></script>

<script language="javascript">

  var main;
  
  window.onload = function() {
    main = new dBox("main");
    main.initialize();    
    main.boxOn();	
    
    //The following works for zoomin and zoomout 
    //but returns strange things after dragging
    main.setHandler(DBOX_SETBOX, main_setbox);
    function main_setbox(minx, miny, maxx, maxy) {
      //I just need a good rectangle also after dragging
      alert (minx + ", " + miny + ", " + maxx + ", " + maxy);
    }    
  }
 
</script>

<img id="main" width="640" height="480" />

<P></P>

<input type="button" value="Zoom in"  onclick="main.boxOn();">
<input type="button" value="Zoom out" onclick="main.boxOff();">
<input type="button" value="Pan" onclick="main.dragOn();">


Thank you for any hint!

Mauro Sartori



More information about the mapserver-users mailing list