This page describes an older version, please see latest API at http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/tasks/Locator.html.
Packagecom.esri.ags.tasks
Classpublic class Locator
InheritanceLocator Inheritance BaseTask Inheritance flash.events.EventDispatcher

Represents a geocode service resource exposed by the ArcGIS Server REST API (available in ArcGIS Server 9.3 and higher). It is used to generate candidates for an address. It is also used to find an address for a given location.

Set the URL to the ArcGIS Server REST resource that represents a Locator service, for example, http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_NA/GeocodeServer. For more information on constructing a URL, see Using the ArcGIS Services Directory.

See also

com.esri.ags.events.LocatorEvent
Live Sample - using addressToLocations() with a Locator.
Live Sample - using arealengthsComplete and simplifyComplete with a GeometryService.
Geocode Service (REST documentation)


Public Properties
 PropertyDefined By
  addressToLocationsLastResult : Array
Array of AdressCandidate object returned from last call to the addressToLocations function.
Locator
 InheritedautoNormalize : Boolean
If true, normalizes the geometries across the central meridian.
BaseTask
 Inheritedconcurrency : String
Value that indicates how to handle multiple calls to the same task.
BaseTask
 InheriteddisableClientCaching : 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
  locationToAddressLastResult : AddressCandidate
The result from the most recent locationToAddress call.
Locator
 Inheritedmethod : String
URL request method to use.
BaseTask
  outSpatialReference : SpatialReference
The spatial reference of the output geometries.
Locator
 InheritedproxyURL : String
The URL to proxy the request through.
BaseTask
 InheritedrequestTimeout : int
The request timeout in seconds.
BaseTask
 InheritedshowBusyCursor : Boolean
If true, a busy cursor is displayed while a service is executing.
BaseTask
 Inheritedtoken : String
Token for accessing a secure task.
BaseTask
 Inheritedurl : String
URL of the task.
BaseTask
Public Methods
 MethodDefined By
  
Locator(url:String = null)
Creates a new Locator object.
Locator
  
addressToLocations(address:Object, outFields:Array = null, responder:IResponder = null):AsyncToken
Sends a request to the ArcGIS REST geocode resource to find candidates for a single address specified in the address argument.
Locator
  
locationToAddress(location:MapPoint, distance:Number = 0, responder:IResponder = null):AsyncToken
Locates an address based on a given point.
Locator
Protected Methods
 MethodDefined By
 Inherited
sendURLVariables(urlSuffix:String, urlVariables:URLVariables, responder:IResponder, operation:Function):AsyncToken
Sends an HTTP request.
BaseTask
Events
 Event Summary Defined By
  Dispatched when an addressToLocations operation successfully completes.Locator
  Dispatched when a Locator request fails.Locator
  Dispatched when a locationToAddress operation successfully completes.Locator
Property Detail
addressToLocationsLastResultproperty
addressToLocationsLastResult:Array

Array of AdressCandidate object returned from last call to the addressToLocations function.

This property can be used as the source for data binding.


Implementation
    public function get addressToLocationsLastResult():Array
    public function set addressToLocationsLastResult(value:Array):void

See also

locationToAddressLastResultproperty 
locationToAddressLastResult:AddressCandidate

The result from the most recent locationToAddress call.

This property can be used as the source for data binding.


Implementation
    public function get locationToAddressLastResult():AddressCandidate
    public function set locationToAddressLastResult(value:AddressCandidate):void
outSpatialReferenceproperty 
outSpatialReference:SpatialReference

The spatial reference of the output geometries. If not specified, the output geometries are in the spatial reference of the Locator service. Only available with ArcGIS Server 10.0 and higher.

This property can be used as the source for data binding.


Implementation
    public function get outSpatialReference():SpatialReference
    public function set outSpatialReference(value:SpatialReference):void
Constructor Detail
Locator()Constructor
public function Locator(url:String = null)

Creates a new Locator object.

Parameters
url:String (default = null) — [optional] URL to the ArcGIS Server REST resource that represents a Locator service.
Method Detail
addressToLocations()method
public function addressToLocations(address:Object, outFields:Array = null, responder:IResponder = null):AsyncToken

Sends a request to the ArcGIS REST geocode resource to find candidates for a single address specified in the address argument. On completion, the addressToLocationsComplete event is fired and the optional callback responder is invoked.

Parameters

address:Object — The address object.
 
outFields:Array (default = null) — The array of fields to include in the returned result set. If you specify the shape field in the list of return fields, it is ignored. For non-intersection addresses you can specify the candidate fields as defined in the geocode service. For intersection addresses you can specify the intersection candidate fields.
 
responder:IResponder (default = null) — The responder to call on result or fault.
locateTask.addressToLocations(myAddress, myOutFields, new AsyncResponder(onResult, onFault));

Returns
AsyncToken
locationToAddress()method 
public function locationToAddress(location:MapPoint, distance:Number = 0, responder:IResponder = null):AsyncToken

Locates an address based on a given point.

Parameters

location:MapPoint — The point at which to search for the closest address.
 
distance:Number (default = 0) — The distance in meters from the given location within which a matching address should be searched. If this parameter is not provided or an invalid value is provided, a default value of 0 meters is used.
 
responder:IResponder (default = null) — The responder to call on result or fault.
     locateTask.locationToAddress(myMapPoint, 100);

Returns
AsyncToken
Event Detail
addressToLocationsComplete Event
Event Object Type: com.esri.ags.events.LocatorEvent
LocatorEvent.type property = com.esri.ags.events.LocatorEvent.ADDRESS_TO_LOCATIONS_COMPLETE

Dispatched when an addressToLocations operation successfully completes.

Defines the value of the type property of an addressToLocationsComplete event object.
fault Event  
Event Object Type: mx.rpc.events.FaultEvent
FaultEvent.type property = mx.rpc.events.FaultEvent.FAULT

Dispatched when a Locator request fails. Applies to both methods.

locationToAddressComplete Event  
Event Object Type: com.esri.ags.events.LocatorEvent
LocatorEvent.type property = com.esri.ags.events.LocatorEvent.LOCATION_TO_ADDRESS_COMPLETE

Dispatched when a locationToAddress operation successfully completes.

Defines the value of the type property of a locationToAddressComplete event object.