[mapguide-trac] #518: Zoom Rectangle calculation assumes lower-left to upper-right dragging in AJAX Viewer

MapGuide Open Source trac_mapguide at osgeo.org
Tue Mar 25 15:36:08 EDT 2008


#518: Zoom Rectangle calculation assumes lower-left to upper-right dragging in
AJAX Viewer
---------------------------+------------------------------------------------
   Reporter:  nclayton     |       Owner:                
       Type:  defect       |      Status:  new           
   Priority:  medium       |   Milestone:                
  Component:  AJAX Viewer  |     Version:  2.0.0         
   Severity:  minor        |    Keywords:  Zoom Rectangle
External_id:               |  
---------------------------+------------------------------------------------
 In ajaxmappage.templ, the code assumes that users will always go lower-
 left to upper-right when drawing the Zoom Rectangle box.
 {{{
         pt1 = ScreenToMapUnits(x1, y1);
         pt2 = ScreenToMapUnits(x2, y2);

         mcsW = pt2.X - pt1.X;
         mcsH = pt2.Y - pt1.Y;
 }}}

 If a user (like myself) drags from upper-right to lower-left, mcsW and/or
 mcsH will be a negative value which will throw off the zoom operation.

 By checking for a negative value then multiplying by -1 after the
 assignment will give accurate width and height values for the drawn box:
 {{{
 if(mcsW < 0){ mcsW = mcsW * -1; }
 if(mcsH < 0){ mcsH = mcsH * -1; }
 }}}

 Once these values are corrected, you'll need to find the lower X,Y values:
 {{{
 var lowX = (pt1.X < pt2.X? pt1.X: pt2.X);
 var lowY = (pt1.Y < pt2.Y? pt1.Y: pt2.Y);
 }}}

 Then calculate the view by adding the width/2 and height/2 values to the
 lowX and lowY values:
 {{{
 GotoView(lowX + mcsW/2, lowY + mcsH/2, scale, true, false);
 }}}

 I have set the Severity to minor, but for myself this was a major issue
 and I resolved it in my file.

 I have not ran across it, but there may be other areas where drag
 direction is assumed and could sometimes be inaccurate.

-- 
Ticket URL: <http://trac.osgeo.org/mapguide/ticket/518>
MapGuide Open Source <http://mapguide.osgeo.org/>
MapGuide Open Source Internals


More information about the mapguide-trac mailing list