Select to view content in your preferred language

modify Find Task Zoom In Results Sample?

1688
3
12-28-2010 11:56 AM
by Anonymous User
Not applicable
Original User: alnesbit

Hello all,

So my end goal is something much larger (http://forums.arcgis.com/threads/19195-enter-address-but-zoom-to-polling-place) on ags 9.3 with flex 2.2. But I'm just starting to learn Flex so I wanted to take an existing sample, the one called Zoom to Found Features http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=FindTask_ZoomInResults and modify it.

It's not working right so I'm hoping someone can show me what I'm missing. (My development environment is ags 10). It finds my feature but it doesn't zoom to the feature. I changed it to a point feature class instead of a polygon. I will attach my code.

Appreciate any help. Thanks,
0 Kudos
3 Replies
by Anonymous User
Not applicable
Original User: rscheitlin

Andrea,

   You are having an issue with trying to set the maps extent to a null extent because you are get one MapPoint back and MapPoints don't have an extent.

Corrected code:
import com.esri.ags.geometry.MapPoint;

private function executeCompleteHandler(event:FindEvent):void
   {
    myGraphicsLayer.clear();
    
    resultSummary.text = "Found " + event.findResults.length + " results.";
    myGraphicsLayer.symbol = sfsFind;
    
    var resultCount:int = event.findResults.length;
    
    if (resultCount == 0)
    {
     Alert.show("No polling places found. Please change your search.");
    }
    else
    {
     // add feature as graphic to graphics layer
     for (var i:int = 0; i < resultCount; i++)
     {
      var graphic:Graphic = FindResult(event.findResults).feature;
      graphic.toolTip = event.findResults.foundFieldName + ": " + event.findResults.value;
      myGraphicsLayer.add(graphic);
     }
     
     // zoom to extent of all features
     var graphicProvider:ArrayCollection = myGraphicsLayer.graphicProvider as ArrayCollection;
     var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(graphicProvider.toArray());
     if(graphicsExtent){
      map.extent = graphicsExtent.expand(1.1); // zoom out a little
     }else{
      var gra:Graphic = FindResult(event.findResults[0]).feature;
      if(gra.geometry is MapPoint){
       map.centerAt(gra.geometry as MapPoint);
       map.scale = 5000;
      }
     }
    }
   }
0 Kudos
by Anonymous User
Not applicable
Original User: alnesbit

Robert,

This works perfectly. Thanks again!

What path did you take to learn all of this? I have a couple of flex books but they aren't specific to ESRI so I'm getting lost.
0 Kudos
tanyabisen
Emerging Contributor
Hi Robert,

I am trying to work on the same sample Zoom to Found Features http://help.arcgis.com/en/webapi/fle..._ZoomInResults and modify it and I am using Bing maps as my basemap and overlaying my layer over it.I am trying to zoom for single or multipoint feature class.

I tried using the solution which u posted for Andrea but for me it doesnt work.

For spatial query its working fine but for attribute query I am facing extent issues. I am new to this platform..I am attaching my code in the text file.

Appreciate any help..Thanks

Tanya Bisen
0 Kudos