| Package | com.esri.ags.tasks |
| Class | public class FindTask |
| Inheritance | FindTask BaseTask flash.events.EventDispatcher |
Set the url to the ArcGIS Server REST resource that represents a FindTask, e.g. http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Portland/Portland_ESRI_LandBase_AGO/MapServer. For more information on constructing a URL, see Using the ArcGIS Services Directory.
See also
| Property | Defined by | ||
|---|---|---|---|
![]() | concurrency : String = "multiple"
Value that indicates how to handle multiple calls to the same task.
| BaseTask | |
![]() | disableClientCaching : Boolean
If true, adds a timestamp parameter ("_ts") to the REST request to prevent the request from
being loaded from the browser's cache.
| BaseTask | |
| executeLastResult : Array
The last result of the execute function.
| FindTask | ||
![]() | proxyURL : String
The URL to proxy the request through.
| BaseTask | |
![]() | requestTimeout : Number = -1
The request timeout in seconds.
| BaseTask | |
![]() | showBusyCursor : Boolean = false
If true, a busy cursor is displayed while a service is executing.
| BaseTask | |
![]() | token : String
Token for accessing a secure task.
| BaseTask | |
![]() | url : String
URL of the task.
| BaseTask | |
| Method | Defined by | ||
|---|---|---|---|
|
FindTask(url:String = null)
Creates a new FindTask object.
| FindTask | ||
|
execute(findParameters:FindParameters, responder:IResponder = null):AsyncToken
Sends a request to the ArcGIS REST map service resource to perform a search based
on the FindParameters specified in the findParameters argument.
| FindTask | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched on success. | FindTask | |||
| Dispatched when a FindTask fails. | FindTask | |||
| executeLastResult | property |
public var executeLastResult:ArrayThe last result of the execute function.
This property can be used as the source for data binding.
See also
| FindTask | () | constructor |
public function FindTask(url:String = null)Creates a new FindTask object.
Parametersurl:String (default = null) — [optional] URL to the ArcGIS Server REST resource that represents a map layer.
|
| execute | () | method |
public function execute(findParameters:FindParameters, responder:IResponder = null):AsyncTokenSends a request to the ArcGIS REST map service resource to perform a search based on the FindParameters specified in the findParameters argument. On completion, the findComplete event is fired and the optional callback function is invoked.
ParametersfindParameters:FindParameters |
|
responder:IResponder (default = null) |
AsyncToken |
| executeComplete | event |
com.esri.ags.events.FindEvent
com.esri.ags.events.FindEvent.EXECUTE_COMPLETE
Dispatched on success.
Defines the value of the type property of an executeComplete event object.
| fault | event |
<?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="Find features in Map Layers"
styleName="plain"
>
<!--
How to search your data using the find task:
The FindParameters designate which layers and fields will be searched.
If multiple layers contain the same field name (for example "NAME")
both fields will be searched.
Note that in this example returnGeometry is set to true so that the results
can be displayed on the map.
The searchText of the FindParameters is what the task will search for.
This text comes from the input box and is sent to the execute function when
you click the Find button. This line executes the task:
findTask.execute( myFindParams);
When the task finishes executing, the executeCompleteHandler function loops
through the array of graphics in the FindResult and adds each graphic to the map.
The datagrid at the bottom gets its content directly from the task:
dataProvider="{findTask.findLastResult}"
-->
<mx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.events.FindEvent;
import com.esri.ags.geometry.Geometry;
private function doFind():void
{
findTask.execute( myFindParams );
}
private function executeCompleteHandler( event : FindEvent ) : void
{
myGraphicsLayer.clear();
var graphic : Graphic;
resultSummary.text = "Found " + event.findResults.length + " results.";
for (var i : Number = 0; i < event.findResults.length; i++)
{
graphic = event.findResults[i].feature;
graphic.toolTip = event.findResults[i].foundFieldName + ": " + event.findResults[i].value;
switch (graphic.geometry.type)
{
case Geometry.MAPPOINT:
graphic.symbol = smsFind;
break;
case Geometry.POLYLINE:
graphic.symbol = slsFind;
break;
case Geometry.POLYGON:
graphic.symbol = sfsFind;
break;
}
myGraphicsLayer.add(graphic);
}
}
]]>
</mx:Script>
<!-- Symbol for Find Result as Polyline -->
<esri:SimpleLineSymbol id="slsFind" style="solid" color="0xFFFF00" width="3" alpha="0.9"/>
<!-- Symbol for Find Result as Point -->
<esri:SimpleMarkerSymbol id="smsFind" style="square" color="0xFFFF00" size="11" alpha="0.9">
<esri:SimpleLineSymbol color="0x000000"/>
</esri:SimpleMarkerSymbol>
<!-- Symbol for Find Result as Polygon -->
<esri:SimpleFillSymbol id="sfsFind" color="0xFFFF00" alpha="0.7"/>
<!-- Find Task -->
<esri:FindTask
id="findTask"
executeComplete="executeCompleteHandler(event)"
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer"
/>
<esri:FindParameters id="myFindParams"
returnGeometry="true"
contains="true"
searchText="{fText.text}"
layerIds="[0,1,2]"
searchFields="['CITY_NAME','NAME','SYSTEM','STATE_ABBR','STATE_NAME']"
/>
<mx:HBox width="100%" height="40" backgroundColor="0xDDDDFF" paddingTop="10" horizontalAlign="center">
<mx:Text text="Search for names of States, Cities, and Rivers:"/>
<mx:TextInput maxWidth="400" id="fText" enter="doFind()" text="Paradise"/>
<mx:Button label="Find" click="doFind()"/>
</mx:HBox>
<mx:Text id="resultSummary" height="15"/>
<mx:VDividedBox height="100%" width="100%">
<esri: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://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer"/>
<esri:GraphicsLayer id="myGraphicsLayer"/>
</esri:Map>
<mx:DataGrid
dataProvider="{findTask.executeLastResult}"
scroll="true" width="100%" height="40%">
<mx:columns>
<mx:DataGridColumn dataField="layerId" headerText="Layer ID" width="70"/>
<mx:DataGridColumn dataField="layerName" headerText="Layer Name"/>
<mx:DataGridColumn dataField="foundFieldName" headerText="Found Field Name"/>
<mx:DataGridColumn dataField="value" headerText="Found Field Value"/>
</mx:columns>
</mx:DataGrid>
</mx:VDividedBox>
</mx:Application>