Select to view content in your preferred language

get distinct attribute values from featureservice

3147
2
09-15-2013 05:19 AM
AndrzejMilosz
Deactivated User
I'm looking for solution how can I get distinct attribute values from featureservice (types of hikingtrails). Later I want to put them in my combobox in flex webapplication. What is the best solution to get values? Is in API for Flex sometnig like SearchCursor I use in python?
Tags (2)
0 Kudos
2 Replies
AnthonyGiles
Honored Contributor
Andrezj,

Are you using server 10.1 as there was an extra attribute added to the query function with service pack 1 that allows you to return unique values.

returnDistinctValues //This option was added at 10.1 SP1

Description: If true then returns distinct values based on the fields specified in outFields. This parameter applies only if supportsAdvancedQueries property of the layer is true.

Syntax: returnDistinctValues=<true | false>
Example: returnDistinctValues=true

See:

http://resources.arcgis.com/en/help/rest/apiref/

Regards

Anthony
0 Kudos
KomanDiabate
Deactivated User
Check this out....

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
 xmlns:mx="http://www.adobe.com/2006/mxml"
 xmlns:esri="http://www.esri.com/2008/ags"
 pageTitle="Query, then zoom to results"
 styleName="plain"
 initialize="init()">
 
 <mx:Script>
  <![CDATA[
   import com.esri.ags.Graphic;
   import com.esri.ags.geometry.Polygon;
   import com.esri.ags.FeatureSet;
   import mx.controls.Alert;
   import mx.rpc.AsyncResponder;
   import mx.collections.ArrayCollection;
   
   [Bindable]
   public var myAC:ArrayCollection = new ArrayCollection();
   [Bindable]
   public var myQueryString:String = "%";
   
   
   
   private function init():void
   {
    
    queryTask.execute(initquery, new AsyncResponder(onResult, onFault));
    
    function onResult(featureSet:FeatureSet, token:Object = null):void
    {
     
     for each (var myGraphic1:Graphic in featureSet.features)
     {
      myAC.addItem(myGraphic1.attributes.PROJECTID);
     }    
    }
    
    function onFault(info:Object, token:Object = null):void
    {
     Alert.show(info.toString());
    }
    
   }
   
   
  ]]>
 </mx:Script>
 
 <!-- Start Declarations -->
 <!-- Symbol for Query Result as Polygon -->
 <esri:SimpleFillSymbol id="sfs" alpha="0.7" color="0xFF0000"/>
 
 <!-- Layer with US States -->
 <esri:QueryTask id="queryTask"
     url="http://......"/>
 
 <esri:Query id="initquery" text="{myQueryString}"
    returnGeometry="false" outSpatialReference="{map.spatialReference}">
  <esri:outFields>
   <mx:String>*</mx:String>
  </esri:outFields>
 </esri:Query>
 
 
 
 <mx:HBox width="100%" height="40" backgroundColor="0xDDDDFF" paddingTop="10" horizontalAlign="center">
  <mx:Label text="Project ID"/>
  <mx:ComboBox id="QueryComboBox" dataProvider="{myAC}">      </mx:ComboBox>
  
 </mx:HBox>
 
 
 <mx:VDividedBox height="100%" width="100%">
  
  <esri:Map id="map">
   <esri:extent>
    <esri:Extent xmin="-126" ymin="24" xmax="-67" ymax="50">
     <esri:SpatialReference wkid="4326"/>
    </esri:Extent>
   </esri:extent>
   <esri:ArcGISDynamicMapServiceLayer
    url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer"/>
   <esri:GraphicsLayer id="myGraphicsLayer" symbol="{sfs}"/>
  </esri:Map>
  
 </mx:VDividedBox>
</mx:Application>
0 Kudos