zooming and panning with dbox

Steve Lime Steve.Lime at DNR.STATE.MN.US
Mon Dec 17 17:24:13 EST 2007


In dBox a drag is just a surrogate for a click. As you drag the image
you are defining
a the click necessary to produce the next map. That click coordinate is
held in minx,miny
and is accessible via the setbox handler just as you show below. The
coordinate where
the mouse up event is fired after a drag is started is not available
through the dBox
API. You could alter dbox.js to change that behavior pretty easily. 

Steve

>>> On 12/17/2007 at 6:26 AM, in message
<JT718C$D27743DF746F4FEEF4E5089FB75C6C84 at libero.it>, "maurosa at iol.it"
<maurosa at IOL.IT> wrote:
> 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