ArcGIS Runtime SDK for iOS: AGSLocatorTask Class Reference
ArcGIS Runtime SDK for iOS  100.7
AGSLocatorTask Class Reference

Description

A task to geocode and reverse-geocode addresses and places.

Instances of this class represent a task used to convert an address to a point (geocode) or vice-versa (reverse geocode). It also supports finding well known places and points of interest, and can provide suggestions character-by-character as a user types.

The task can be created for an ArcGIS Geocode service hosted in the cloud on ArcGIS Online or on-premises with ArcGIS Server. The task can also be created for a locator dataset stored locally on the device in which case it can used even when the device has no network connectivity.

Since
100
See also
https://developers.arcgis.com/features/geocoding/
Inheritance diagram for AGSLocatorTask:
AGSLoadableRemoteResourceBase AGSLoadableBase <AGSRemoteResource> AGSObject <AGSLoadable>

Instance Methods

(void) - cancelLoad
 
(id< AGSCancelable >) - geocodeWithSearchText:completion:
 
(id< AGSCancelable >) - geocodeWithSearchText:parameters:completion:
 
(id< AGSCancelable >) - geocodeWithSearchValues:completion:
 
(id< AGSCancelable >) - geocodeWithSearchValues:parameters:completion:
 
(id< AGSCancelable >) - geocodeWithSuggestResult:completion:
 
(id< AGSCancelable >) - geocodeWithSuggestResult:parameters:completion:
 
(instancetype) - initWithName:
 
(instancetype) - initWithURL:
 
(void) - loadWithCompletion:
 
(void) - retryLoadWithCompletion:
 
(id< AGSCancelable >) - reverseGeocodeWithLocation:completion:
 
(id< AGSCancelable >) - reverseGeocodeWithLocation:parameters:completion:
 
(id< AGSCancelable >) - suggestWithSearchText:completion:
 
(id< AGSCancelable >) - suggestWithSearchText:parameters:completion:
 

Class Methods

(instancetype) + locatorTaskWithName:
 
(instancetype) + locatorTaskWithURL:
 

Properties

AGSCredentialcredential
 
NSError * loadError
 
AGSLoadStatus loadStatus
 
AGSLocatorInfolocatorInfo
 
AGSRequestConfigurationrequestConfiguration
 
NSURL * URL
 

Method Documentation

§ cancelLoad()

- (void) cancelLoad
requiredinherited

Cancels loading if it is in progress, otherwise it does nothing. This should be called carefully because other objects could be waiting for loadWithCompletion: or retryLoadWithCompletion: to complete and this will call them all back with the error of NSUserCancelledError

Since
100

§ geocodeWithSearchText:completion:()

- (id<AGSCancelable>) geocodeWithSearchText: (NSString *)  searchText
completion: (void(^)(NSArray< AGSGeocodeResult * > *__nullable geocodeResults, NSError *__nullable error))  completion 

Perform a geocode operation to find location candidates for the provided text.

Parameters
searchTextto geocode. Can be an address (such as "380 New York St" or "380 New York St, Redlands, California, 92373") or the name of a well known place (such as "Disneyland")
completionblock that is invoked when the operation completes. The results are populated if the operation succeeds, else the error is populated if the operation fails.
Returns
operation that can be canceled
Since
100

§ geocodeWithSearchText:parameters:completion:()

- (id<AGSCancelable>) geocodeWithSearchText: (NSString *)  searchText
parameters: (AGSGeocodeParameters *)  parameters
completion: (void(^)(NSArray< AGSGeocodeResult * > *__nullable geocodeResults, NSError *__nullable error))  completion 

Perform a geocode operation to find location candidates for the provided text.

Parameters
searchTextto geocode. Can be an address (such as "380 New York St" or "380 New York St, Redlands, California, 92373") or the name of a well known place (such as "Disneyland")
parametersto refine the results returned
completionblock that is invoked when the operation completes. The results are populated if the operation succeeds, else the error is populated if the operation fails.
Returns
operation that can be canceled
Since
100

§ geocodeWithSearchValues:completion:()

- (id<AGSCancelable>) geocodeWithSearchValues: (NSDictionary< NSString *, NSString * > *)  searchValues
completion: (void(^)(NSArray< AGSGeocodeResult * > *__nullable geocodeResults, NSError *__nullable error))  completion 

Perform a geocode operation to find location candidates for the provided values of a multi-line address.

Parameters
searchValuesto geocode. Each value represents an individual address component of a multi-line address. The address components supported are defined by AGSLocatorInfo::searchAttributes. The key of this dictionary should match AGSLocatorAttribute::name, and the value in the input for that address component.
completionblock that is invoked when the operation completes. The results are populated if the operation succeeds, else the error is populated if the operation fails.
Returns
operation that can be canceled
Since
100

§ geocodeWithSearchValues:parameters:completion:()

- (id<AGSCancelable>) geocodeWithSearchValues: (NSDictionary< NSString *, NSString * > *)  searchValues
parameters: (AGSGeocodeParameters *)  parameters
completion: (void(^)(NSArray< AGSGeocodeResult * > *__nullable geocodeResults, NSError *__nullable error))  completion 

Perform a geocode operation to find location candidates for the provided values of a multi-line address.

Parameters
searchValuesto geocode. Each value represents an individual address component of a multi-line address. The address components supported are defined by AGSLocatorInfo::searchAttributes. The key of this dictionary should match AGSLocatorAttribute::name, and the value in the input for that address component.
parametersto refine the results returned
completionblock that is invoked when the operation completes. The results are populated if the operation succeeds, else the error is populated if the operation fails.
Returns
operation that can be canceled
Since
100

§ geocodeWithSuggestResult:completion:()

- (id<AGSCancelable>) geocodeWithSuggestResult: (AGSSuggestResult *)  suggestResult
completion: (void(^)(NSArray< AGSGeocodeResult * > *__nullable geocodeResults, NSError *__nullable error))  completion 

Perform a geocode operation to find location candidates for a suggestion provided by suggestWithSearchText:completion:

Parameters
suggestResultsuggestion to geocode
completionblock that is invoked when the operation completes. The results are populated if the operation succeeds, else the error is populated if the operation fails.
Returns
operation that can be canceled
Since
100

§ geocodeWithSuggestResult:parameters:completion:()

- (id<AGSCancelable>) geocodeWithSuggestResult: (AGSSuggestResult *)  suggestResult
parameters: (AGSGeocodeParameters *)  parameters
completion: (void(^)(NSArray< AGSGeocodeResult * > *__nullable geocodeResults, NSError *__nullable error))  completion 

Perform a geocode operation to find location candidates for a suggestion provided by suggestWithSearchText:parameters:completion:

Parameters
suggestResultsuggestion to geocode
parametersto refine the results returned. Note: The parameters must match the original criteria specified in the AGSSuggestParameters, if suggestWithSearchText:parameters:completion: was used to produce the suggestResult
completionblock that is invoked when the operation completes. The results are populated if the operation succeeds, else the error is populated if the operation fails.
Returns
operation that can be canceled
Since
100

§ initWithName:()

- (instancetype) initWithName: (NSString *)  name

Initialize the task with the name of a locator dataset within the application bundle or shared documents directory.

Parameters
nameof the locator dataset (same as the name of the .loc file without the file extension)
Returns
initialized locator task
Since
100

§ initWithURL:()

- (instancetype) initWithURL: (NSURL *)  URL

Initialize the task with a URL to a remote ArcGIS Geocode service or a locator dataset (.loc file) on disk.

Parameters
URLto a remote ArcGIS Geocode service or a locator dataset (.loc file) on disk.
Returns
initialized locator task
Since
100

§ loadWithCompletion:()

- (void) loadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Loads data for the object asynchronously. The completion block is invoked upon completion.

You can call this method any number of times, however only one attempt is made to load the data. If it is already loading, it will just continue to load (i.e. not force a reload). If it has already loaded successfully, the completion block will be invoked right away. If it has already failed to load, the completion block will be invoked right away with error previously encountered. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100
See also
- cancelLoad to cancel loading
- retryLoadWithCompletion: to force reload

§ locatorTaskWithName:()

+ (instancetype) locatorTaskWithName: (NSString *)  name

Initialize the task with the name of a locator dataset within the application bundle or shared documents directory.

Parameters
nameof the locator dataset (same as the name of the .loc file without the file extension)
Returns
initialized locator task
Since
100

§ locatorTaskWithURL:()

+ (instancetype) locatorTaskWithURL: (NSURL *)  URL

Initialize the task with a URL to a remote ArcGIS Geocode service or a locator dataset (.loc file) on disk.

Parameters
URLto a remote ArcGIS Geocode service or a locator dataset (.loc file) on disk.
Returns
initialized locator task
Since
100

§ retryLoadWithCompletion:()

- (void) retryLoadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Tries to reload when an object has failed to load. This method should be called judiciously. It should be called when:

  1. you didn't have network connectivity earlier when it failed and you want to retry now that you have connectivity
  2. the server was down earlier when it failed and you want to retry
  3. the request is taking too long and you want to cancel it and retry, in which case you will first call cancelLoad and then this method

If the data hasn't started loading, it will start loading. If it is already loading, it will just continue to load. If it has already loaded successfully, calls back right away. If it has already failed to load, tries again. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100

§ reverseGeocodeWithLocation:completion:()

- (id<AGSCancelable>) reverseGeocodeWithLocation: (AGSPoint *)  location
completion: (void(^)(NSArray< AGSGeocodeResult * > *__nullable geocodeResults, NSError *__nullable error))  completion 

Perform a reverse geocode operation to find address candidates for the provided location.

Parameters
locationto reverse geocode
completionblock that is invoked when the operation completes. The results are populated if the operation succeeds, else the error is populated if the operation fails.
Returns
operation that can be canceled
Since
100

§ reverseGeocodeWithLocation:parameters:completion:()

- (id<AGSCancelable>) reverseGeocodeWithLocation: (AGSPoint *)  location
parameters: (AGSReverseGeocodeParameters *)  parameters
completion: (void(^)(NSArray< AGSGeocodeResult * > *__nullable geocodeResults, NSError *__nullable error))  completion 

Perform a reverse geocode operation to find address candidates for the provided location.

Parameters
locationto reverse geocode
parametersto refine the results returned
completionblock that is invoked when the operation completes. The results are populated if the operation succeeds, else the error is populated if the operation fails.
Returns
operation that can be canceled
Since
100

§ suggestWithSearchText:completion:()

- (id<AGSCancelable>) suggestWithSearchText: (NSString *)  searchText
completion: (void(^)(NSArray< AGSSuggestResult * > *__nullable suggestResults, NSError *__nullable error))  completion 

Find suggestions for the provided text. Suggestion results are intended to be displayed as a user enters text character-by-character into a search box. When the user picks a suggestion, you will need to use geocodeWithSuggestResult:completion: to find the location candidates for the suggestion.

Parameters
searchTextto find suggestions for
completionblock that is invoked when the operation completes. The results are populated if the operation succeeds, else the error is populated if the operation fails.
Returns
operation that can be canceled
Since
100

§ suggestWithSearchText:parameters:completion:()

- (id<AGSCancelable>) suggestWithSearchText: (NSString *)  searchText
parameters: (AGSSuggestParameters *)  parameters
completion: (void(^)(NSArray< AGSSuggestResult * > *__nullable suggestResults, NSError *__nullable error))  completion 

Find suggestions for the provided text. Suggestion results are intended to be displayed as a user enters text character-by-character into a search box. When the user picks a suggestion, you will need to use geocodeWithSuggestResult:parameters:completion: to find the location candidates for the suggestion.

Parameters
searchTextto find suggestions for
parametersto refine the results returned.
completionblock that is invoked when the operation completes. The results are populated if the operation succeeds, else the error is populated if the operation fails.
Returns
operation that can be canceled
Since
100

Property Documentation

§ credential

- (AGSCredential*) credential
readwritenonatomicstronginherited

Security credentials to access the remote resource. Only applicable if the resource is secured.

Since
100

§ loadError

- (NSError*) loadError
readnonatomicstronginherited

The error that was encountered during the most recent load operation. Will be nil if the operation succeeded.

Since
100

§ loadStatus

- (AGSLoadStatus) loadStatus
readrequirednonatomicassigninherited

Status of the load operation.

Since
100

§ locatorInfo

- (AGSLocatorInfo*) locatorInfo
readnonatomicstrong

Metadata about the ArcGIS Geocode service or locator dataset being used by the task

Since
100

§ requestConfiguration

- (AGSRequestConfiguration*) requestConfiguration
readwritenonatomicstronginherited

The AGSRequestConfiguration object which defines the behavior and policies to use when accessing the remote resource. The default will be nil. If it is nil the [AGSRequestConfiguration globalConfiguration] will be used.

Since
100

§ URL

- (NSURL*) URL
readrequirednonatomicstronginherited

The URL of the remote resource.

Since
100