I need to create a widget to show all the data of a ArcGIS map server; need to create a comboBox so that all the city's population information can show up in it. Should i use <mx WebService>, or should I use ESRI:query?
If I use query, each time I have query according to city name, that means I can only get one city's population info each time. But I need all of them. Thanks!
You can use the ESRI query. If you set the where clause to equal 1=1 it will always be true and send you all the data back.Here is a sample
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:esri="http://www.esri.com/2008/ags"
xmlns:s="library://ns.adobe.com/flex/spark"
pageTitle="Query Task Sample">
<s:layout>
<s:VerticalLayout horizontalAlign="center" paddingTop="25"/>
</s:layout>
<fx:Declarations>
<esri:QueryTask id="queryTask"
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"
useAMF="false"/>
<esri:Query id="query"
outFields="[STATE_NAME,STATE_FIPS,SUB_REGION,STATE_ABBR,POP2000,POP2007]"
returnGeometry="false"
where="1=1"/>
</fx:Declarations>
<s:Panel title="Get All Results">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:HGroup verticalAlign="middle">
<s:Button click="queryTask.execute(query);" label="Get All"/>
</s:HGroup>
<mx:DataGrid id="resultsGrid"
dataProvider="{queryTask.executeLastResult.attributes}"
visible="{queryTask.executeLastResult != null}">
<mx:columns>
<mx:DataGridColumn dataField="STATE_NAME" headerText="State Name"/>
<mx:DataGridColumn dataField="SUB_REGION" headerText="Region"/>
<mx:DataGridColumn dataField="STATE_FIPS" headerText="FIPS"/>
<mx:DataGridColumn dataField="STATE_ABBR" headerText="Abbreviation"/>
<mx:DataGridColumn dataField="POP2000" headerText="Population 2000"/>
<mx:DataGridColumn dataField="POP2007" headerText="Population 2007"/>
</mx:columns>
</mx:DataGrid>
</s:Panel>
</s:Application>
Drew