[mapguide-trac] #1521: Use mouse wheel to zoom map in the "Digitize" process

MapGuide Open Source trac_mapguide at osgeo.org
Fri Nov 12 03:43:59 EST 2010


#1521: Use mouse wheel to zoom map in the "Digitize" process
---------------------------+------------------------------------------------
   Reporter:  wuma         |       Owner:  Mars Wu
       Type:  enhancement  |      Status:  new    
   Priority:  low          |   Milestone:         
  Component:  AJAX Viewer  |     Version:  2.2.0  
   Severity:  minor        |    Keywords:         
External_id:  1309956      |  
---------------------------+------------------------------------------------
 When it is in "Digitize Polygon" or "Digitize LineString" process, there
 is no way to zoom in the map. Sometimes to digitize a precise shape, it's
 necessary to zoom in so that the vertex of the polygon could be digitized
 as precise as possible.

 This patch implements it this way:

 1. Add a ScaleFeedback method for the digitizers. E.g.
 PolygonDigitizer.ScaleFeedback = function(scale, origin)
         {
                 for (var i = 0; i < this.xs.length; ++i)
                 {
                         var x = this.xs[i];
                         this.xs[i] = origin.X + (scale * (x - origin.X));
                         var y = this.ys[i];
                         this.ys[i] = origin.Y + (scale * (y - origin.Y));
                 }

                 this.Feedback(origin.X, origin.Y);
         }

 2. Modify GotoView function in Ajaxmappane.templ to scale the digitize
 feedbacks when the view is changed.
 function GotoView(x,y,scale,tohistory,moveovimg)
 {
     scale = finscale? GetNearestFiniteScale(scale): NormalizeScale(scale);
     var zoom;
     if(zoom = (scale != curScale))
     {
         HideMapImage();
         requestTiles = true;

                 // Update the digitize feedback
                 if (digitizing)
                 {
                         if (typeof digitizer.ScaleFeedback != "undefined")
                         {
                                 digitizer.ScaleFeedback(curScale / scale,
 new Point(wheelZoomCursor.X, wheelZoomCursor.Y));
                         }
                 }
     }
     else
     {....

 Above change can handle the zoom change. The digitize feedbacks will be
 changed after the zoom has finished. The reason why we don't provide a
 "instant" scale feedback (the digitize feedbacks will be updated according
 to every single mouse wheel change) is because redrawing the digitize
 feedbacks needs regenerating hundreds of <div> elements which is very CPU
 consuming.

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


More information about the mapguide-trac mailing list