Select to view content in your preferred language

Flex - zoom to point

2344
2
05-04-2011 05:29 PM
RobertMyers
Deactivated User
The code below will zoom the expand extent of a selected Graphic. I don't understand what the equivalent would be if the Graphic is a point. The point would be selected and zoomed to with a certain extent beyond the location of the point.


  
   private function zoomToRow(graphic:Graphic):void           
   {               
    var offset:int=300;
    var graphicsExtent:Extent;
    if (graphic){
     graphicsExtent = graphic.geometry.extent;
     graphicsExtent.xmax=graphicsExtent.xmax+offset;
     graphicsExtent.xmin=graphicsExtent.xmin-offset;
     graphicsExtent.ymax=graphicsExtent.ymax+offset;
     graphicsExtent.ymin=graphicsExtent.ymin-offset;
     myMap.extent = graphicsExtent
     // make sure the whole extent is visible
     if (!myMap.extent.contains(graphicsExtent)){
      myMap.level--;
     }        
    }
   }
Tags (2)
0 Kudos
2 Replies
RobertMyers
Deactivated User
Just figure it out....may not be pretty.

   private function zoomToRow(graphic:Graphic):void           
   {               
    //var offset:int=300;
    var graphicsExtent:Extent;
    if (graphic){
     //graphicsExtent = graphic.geometry.extent;
     //graphicsExtent.xmax=graphicsExtent.xmax+offset;
     //graphicsExtent.xmin=graphicsExtent.xmin-offset;
     //graphicsExtent.ymax=graphicsExtent.ymax+offset;
     //graphicsExtent.ymin=graphicsExtent.ymin-offset;
     var gra:Graphic = graphic;
     var pt:MapPoint = null;
     pt = gra.geometry as MapPoint;
     myMap.scale = 1200;
     myMap.centerAt(pt);
    
    
    
     //myMap.extent = graphicsExtent
     // make sure the whole extent is visible
     if (!myMap.extent.contains(graphicsExtent)){
      myMap.level--;
     }        
    }
   }
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Robert,

    This is esri's new way of handling zooming to point data

// Zoom to 1/16th the size of the current extent.
                        // This is the same as calling map.zoomIn() four times.
                        map.zoom(1 / 16, mapPoint);
0 Kudos