[Mapserver-users] Re: mouse coordinates

Richard Greenwood rich at greenwoodmap.com
Thu Mar 25 11:17:27 PST 2004


steve mccrone wrote:
> Hi Richard,
> 
> Sorry to bother you again. But I am trying to implement a bearing
> calculation with the measure tool in jBox.
> In order to do this I need the "anchor" mouse coordinate and the current
> mouse coordinate. The current is no problem,
> can get it from the mosuemove handler, but how do I get the initial click
> coordinate in order to calculate the bearing of the line?
> 
> I only see the setbox_handler function, which does not appear to be called
> when the line is on.

You might look at the vertex count (n) which is submitted to 
measure_handler().

Each time the the mouse has moved more than tolerance(pixels) the 
measure_handler() function gets called, and mosuemove_handler() gets 
called if verbose=true. And each time the user clicks in line mode, n 
gets incremented. So code in measure_handler() something like:
   if (n > old_n) {
     anchor.x = mouse.x;
     anchor.y = mouse.y;
     old_n = n;
   }
where mouse.x and mouse.y are being updated by mousemove_handler().

-- 
Richard Greenwood
www.greenwoodmap.com



More information about the MapServer-users mailing list