Zoom to Selection Issues

686
2
05-17-2011 06:47 AM
KevinLaughlin
New Contributor III
Hello All!

I'm new to Flex, so hopefully you bare with me here. I'm using the "Samples" Tab on the ArcGIS API for Flex in ArcGIS Resources to build a simple web application. Everything seems to function just fine except for the fact that the query never returns any results for parcels that I know exist.

As I state earlier, I'm new to Flex development, so I'm starting to spin my wheels here a little bit. I'm thinking it must have something to do with the <esri: Query> declaration, or the <esri: outFields>, but I cannot be sure.

Any and all help will be greatly appreciated and any advice for a novice to Flex would be even better.

Also, I'm using the latest version of Flash and Flash Builder, if that would help at all.

Thanks!

Kevin Laughlin
Wood County, OH

CODE:
==========================================================================

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx"
      xmlns:esri="http://www.esri.com/2008/ags"
      pageTitle="Wood County Planning Commission GIS Portal"
      styleName="plain">

<s:layout>
  <s:VerticalLayout/>
</s:layout>

<fx:Script>
  <![CDATA[
   import com.esri.ags.FeatureSet;
   import com.esri.ags.utils.GraphicUtil;
  
   import mx.controls.Alert;
   import mx.rpc.AsyncResponder;
  
   private function doQuery():void
   {
    // clear the graphics layer
    myGraphicsLayer.clear();
   
    queryTask.execute(query, new AsyncResponder(onResult, onFault));
    function onResult(featureSet:FeatureSet, token:Object = null):void
    {
    
     if (featureSet.features.length == 0)
     {
      Alert.show("No parcels found. Please try again.");
     }
     else
     {
      var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features);
      if (graphicsExtent)
      {
       map.extent = graphicsExtent;
      }
     }
    }
    function onFault(info:Object, token:Object = null):void
    {
     Alert.show(info.toString());
    }
   }
  ]]>
</fx:Script>

<fx:Declarations>
  <esri:SimpleFillSymbol id="sfs"
          alpha="0.7"
          color="0xFF0000"/>
 
  <esri:QueryTask id="queryTask"
      url="http://sdeprod/ArcGIS/rest/services/Planning/MapServer/2"
      useAMF="false"/>
     
  <esri:Query id="query"
     outSpatialReference="{map.spatialReference}"
     returnGeometry="true"
     text="{fText.text}">
   <esri:outFields>
    <fx:String>mpropertyNumber</fx:String>
   </esri:outFields>
  </esri:Query>
</fx:Declarations>

<s:BorderContainer width="100%" height="40"
        backgroundColor="0xDDDDFF"
        borderVisible="false">
  <s:layout>
   <s:HorizontalLayout horizontalAlign="center"
        paddingTop="10"
        verticalAlign="middle"/>
  </s:layout>
  <s:Label text="Search by parcel number:"/>
  <s:TextInput id="fText"
      enter="doQuery()"
      text="Ca"/>
  <s:Button click="doQuery()" label="Query"/>
</s:BorderContainer>

<s:Label id="resultSummary" height="15"/>
<mx:VDividedBox width="100%" height="100%">
  <esri:Map id="map">
   <esri:extent>
    <esri:Extent xmin="1536178.65629639" ymin="539567.489553833" xmax="1770181.98366941" ymax="720930.000497437">
     <esri:SpatialReference wkid="3728"/>
    </esri:Extent>
   </esri:extent>
   <esri:ArcGISDynamicMapServiceLayer url="http://sdeprod/ArcGIS/rest/services/Planning/MapServer"/>
   <esri:GraphicsLayer id="myGraphicsLayer"
        graphicProvider="{queryTask.executeLastResult.features}"
        symbol="{sfs}"/>
  </esri:Map>
  <mx:DataGrid width="100%" height="40%"
      dataProvider="{queryTask.executeLastResult.attributes}"/>
</mx:VDividedBox>
</s:Application>
0 Kudos
2 Replies
derekswingley1
Frequent Contributor
Hi Kevin,

Probably better to post your question here:  http://forums.arcgis.com/forums/18-ArcGIS-API-for-Flex

If you ever dive into the JS API, please come back and we'll be glad to help :).
0 Kudos
KevinLaughlin
New Contributor III
My mistake, thanks for your reply!
0 Kudos