ArcGIS Runtime SDK for iOS: AGSLocatorTask Class Reference
ArcGIS Runtime SDK for iOS  100.15
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 <AGSAPIKeyResource> AGSLoadableBase <AGSRemoteResource> AGSObject <AGSLoadable>

Instance Methods

(void) - cancelLoad
 
(void) - doCancelLoading
 
(void) - doStartLoading:
 
(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) - loadDidFinishWithError:
 
(void) - loadWithCompletion:
 
(void) - onLoadStatusChanged
 
(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

NSString * APIKey
 
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

◆ doCancelLoading

- (void) doCancelLoading

Never call this method directly. The framework calls this method on a background thread when cancelLoad (AGSLoadable-p) is called. It is meant to be overriden by subclasses. Subclasses should override this method to cancel loading their data and call loadDidFinishWithError: (AGSLoadableBase(ForSubclassEyesOnly)) at the end passing in an error representing NSUserCancelledError.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ doStartLoading:

- (void) doStartLoading: (BOOL)  retrying

Never call this method directly. The framework calls this method on a background thread when loadWithCompletion: (AGSLoadable-p) or retryLoadWithCompletion: (AGSLoadable-p) is called. It is meant to be overriden by subclasses. Subclasses should override this method to load their data and call loadDidFinishWithError: (AGSLoadableBase(ForSubclassEyesOnly)) upon completion, passing in the error if any.

Parameters
retryingflag that is true if this method was called from retryLoadWithCompletion: (AGSLoadable-p).
Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ 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

◆ loadDidFinishWithError:

- (void) loadDidFinishWithError: (nullable NSError *)  error

Only subclasses should call this method in doStartLoading: (AGSLoadableBase(ForSubclassEyesOnly)) and doCancelLoading (AGSLoadableBase(ForSubclassEyesOnly)) when done loading or failed to load.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ 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

◆ onLoadStatusChanged

- (void) onLoadStatusChanged

Never call this method directly. The framework calls this method on a background thread when AGSLoadable::loadStatus changes is called. Subclasses can optionally implement this to know when their loading status has changed.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ 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 

Suggest address and returns possible variants. Geocoding suggestions provide a mechanism for implementing character-by-character auto-complete. Using a text input and optional AGSSuggestParameters, suggested addresses can be quickly found and presented to the user. Suggestions are not limited to addresses, they can also be used for POIs (Points of Interest). To return a focused set of suggestions, set the AGSSuggestParameters::preferredSearchLocation or the AGSSuggestParameters::searchArea. Using the AGSSuggestParameters::preferredSearchLocation is similar to how ArcGIS Pro limits the suggestions returned.

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 

Suggest address with parameters and returns possible variants. Geocoding suggestions provide a mechanism for implementing character-by-character auto-complete. Using a text input and optional AGSSuggestParameters, suggested addresses can be quickly found and presented to the user. Suggestions are not limited to addresses, they can also be used for POIs (Points of Interest). To return a focused set of suggestions, set the AGSSuggestParameters::preferredSearchLocation or the AGSSuggestParameters::searchArea. Using the AGSSuggestParameters::preferredSearchLocation is similar to how ArcGIS Pro limits the suggestions returned.

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

◆ APIKey

- (NSString*) APIKey
readwriterequirednonatomiccopyinherited

The API key to access API key enabled services and resources in ArcGIS Online.

An API key is a unique key used to authorize access to specific services and resources in ArcGIS Online. It is also used to monitor access to those services. An API key is created and managed in the ArcGIS developer dashboard and is tied to a specific ArcGIS account.

In addition to setting an API key at a global level for your application using the AGSArcGISRuntimeEnvironment::APIKey property, you can set an AGSAPIKeyResource::APIKey property on any ArcGIS Runtime class that implements AGSAPIKeyResource. When you set an individual AGSAPIKeyResource::APIKey property on an AGSAPIKeyResource it will override the default key at the global level (on the AGSArcGISRuntimeEnvironment::APIKey property, in other words), enabling more granular usage telemetry and management for ArcGIS Online resources used by your app. Classes that expose an API key property by implementing AGSAPIKeyResource include:

◆ 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