ArcGIS Runtime SDK for iOS: AGSAnnotationLayer Class Reference
ArcGIS Runtime SDK for iOS  100.15
AGSAnnotationLayer Class Reference

Description

A layer that can visualize annotation text data. Annotation can be used to symbolize text on your maps as described in the Annotation ArcGIS Pro documentation. Annotation is defined by a text string, geographical location, and display properties including font, size, and color. These are stored together in an annotation feature class within a geodatabase.

There are two kinds of annotation:

  • Standard annotation is not formally associated with features in the geodatabase. An example of standard annotation is the text on a map for a mountain range. No specific feature represents the mountain range, but it is an area you want to mark. Standard annotation is read-only.
  • Feature-linked annotation is associated with a specific feature in another feature class in the geodatabase. The text in feature-linked annotation reflects the value of a field or fields from the feature to which it is linked. For example, the water transmission mains in a water network can be annotated with their names, which are stored in a field in the transmission mains feature class. If you edit the attributes and/or geographical position of the feature associated with the feature-linked annotation, any changes will be applied to the annotation feature table, and visible changes to the annotation will be reflected in the AGSMapView. If the feature-linked annotation is stored in an Enterprise server, its feature and annotation tables must contain global object ids.

You can construct an annotation layer in the following ways:

Annotation layers can be taken offline from a feature service hosted on ArcGIS Enterprise 10.7.1 or later, using the AGSGeodatabaseSyncTask. Annotation layers are also supported in mobile map packages created in ArcGIS Pro 2.3 or later.

Annotation respects the reference scale defined by the map, so annotation will always be presented to the user at the correct size and position, as defined by the annotation author.

Each annotation layer is partitioned into annotation sublayers. Each annotation sublayer corresponds to the label class of the original labels that were used to publish the annotation. In ArcGIS Pro, the annotation sublayers are known as annotation classes.

Annotation sublayers offer greater control over the annotation:

  • An author can set different visual properties on the sublayer compared to the parent annotation layer. For example, font, size, color, or different minimum and maximum scale ranges.
  • You can access the annotation sublayer metadata information, such as the legend information, and set the visibility of each annotation sublayer.
    See also
    AGSLayer, Sample: Display annotation, Sample: Control annotation sublayer visibility
    Since
    100.5
Inheritance diagram for AGSAnnotationLayer:
AGSLayer <AGSRemoteResource> AGSLoadableBase <AGSLayerContent> AGSObject <AGSLoadable>

Instance Methods

(void) - cancelLoad
 
(void) - clearSelection
 
(void) - doCancelLoading
 
(void) - doStartLoading:
 
(id< AGSCancelable >) - fetchLegendInfosWithCompletion:
 
(instancetype) - initWithFeatureTable:
 
(instancetype) - initWithItem:serviceLayerID:
 
(instancetype) - initWithURL:
 
(BOOL) - isEqualToLayer:
 
(BOOL) - isVisibleAtScale:
 
(void) - loadDidFinishWithError:
 
(void) - loadWithCompletion:
 
(void) - onLoadStatusChanged
 
(void) - resetFeaturesVisible
 
(void) - retryLoadWithCompletion:
 
(id< AGSCancelable >) - selectedFeaturesWithCompletion:
 
(void) - selectFeature:
 
(void) - selectFeatures:
 
(id< AGSCancelable >) - selectFeaturesWithParameters:mode:completion:
 
(void) - setFeature:visible:
 
(void) - setFeatures:visible:
 
(void) - unselectFeature:
 
(void) - unselectFeatures:
 

Class Methods

(instancetype) + annotationLayerWithFeatureTable:
 
(instancetype) + annotationLayerWithItem:serviceLayerID:
 
(instancetype) + annotationLayerWithURL:
 

Properties

NSString * attribution
 
AGSLabelBarrierWeight barrierWeight
 
BOOL canChangeVisibility
 
AGSCredentialcredential
 
NSString * definitionExpression
 
AGSArcGISFeatureTablefeatureTable
 
AGSEnvelopefullExtent
 
BOOL identifyEnabled
 
AGSItemitem
 
NSString * layerDescription
 
NSString * layerID
 
NSError * loadError
 
AGSLoadStatus loadStatus
 
double maxScale
 
double minScale
 
NSString * name
 
float opacity
 
double referenceScale
 
AGSRequestConfigurationrequestConfiguration
 
NSInteger serviceLayerID
 
BOOL showInLegend
 
AGSSpatialReferencespatialReference
 
NSArray< id< AGSLayerContent > > * subLayerContents
 
void(^ subLayerContentsChangedHandler )(void)
 
NSURL * URL
 
BOOL visible
 

Method Documentation

◆ annotationLayerWithFeatureTable:

+ (instancetype) annotationLayerWithFeatureTable: (AGSArcGISFeatureTable *)  featureTable

Creates an annotation layer from a feature table containing annotation features. If the feature table does not contain annotation data then the AGSAnnotationLayer will fail to load. AGSArcGISFeatureTable::layerInfo and AGSArcGISFeatureLayerInfo::serviceType can be checked, to verify the feature type, before attempting to create an AGSLayer.

Parameters
featureTableThe feature table, containing annotation features, used as the source of the annotation layer.
See also
AGSArcGISFeatureTable
Since
100.6

◆ annotationLayerWithItem:serviceLayerID:

+ (instancetype) annotationLayerWithItem: (AGSItem *)  item
serviceLayerID: (NSInteger)  serviceLayerID 

Creates a new annotation layer from a feature service portal item.

Parameters
itemA feature service AGSPortalItem.
serviceLayerIDThe ID of the layer in the service for which to create the annotation layer.
See also
AGSLayer::item
Since
100.5

◆ annotationLayerWithURL:

+ (instancetype) annotationLayerWithURL: (NSURL *)  URL

Creates a new annotation layer from a feature service URL. If the specified URL is not a valid Feature Service endpoint, then it will fail to load.

Parameters
URLThe URL to the feature service layer.
Since
100.5

◆ 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

◆ clearSelection

- (void) clearSelection

Updates any selected features in the layer back to the un-selected state.

Since
100.12

◆ 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).

◆ fetchLegendInfosWithCompletion:

- (id<AGSCancelable>) fetchLegendInfosWithCompletion: (void(^)(NSArray< AGSLegendInfo * > *__nullable legendInfos, NSError *__nullable error))  completion

Fetches the array of legend infos (AGSLegendInfo) for this layer.

Since
100

◆ initWithFeatureTable:

- (instancetype) initWithFeatureTable: (AGSArcGISFeatureTable *)  featureTable

Creates an annotation layer from a feature table containing annotation features. If the feature table does not contain annotation data then the AGSAnnotationLayer will fail to load. AGSArcGISFeatureTable::layerInfo and AGSArcGISFeatureLayerInfo::serviceType can be checked, to verify the feature type, before attempting to create an AGSLayer.

Parameters
featureTableThe feature table, containing annotation features, used as the source of the annotation layer.
See also
AGSArcGISFeatureTable
Since
100.6

◆ initWithItem:serviceLayerID:

- (instancetype) initWithItem: (AGSItem *)  item
serviceLayerID: (NSInteger)  serviceLayerID 

Creates a new annotation layer from a feature service portal item.

Parameters
itemA feature service AGSPortalItem.
serviceLayerIDThe ID of the layer in the service for which to create the annotation layer.
See also
AGSLayer::item
Since
100.5

◆ initWithURL:

- (instancetype) initWithURL: (NSURL *)  URL

Creates a new annotation layer from a feature service URL. If the specified URL is not a valid Feature Service endpoint, then it will fail to load.

Parameters
URLThe URL to the feature service layer.
Since
100.5

◆ isEqualToLayer:

- (BOOL) isEqualToLayer: (AGSLayer *)  other

◆ isVisibleAtScale:

- (BOOL) isVisibleAtScale: (double)  scale

Check whether this layer is visible at a given scale.

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

◆ 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).

◆ resetFeaturesVisible

- (void) resetFeaturesVisible

Resets the visibility of the layer's features back to the original visibility when loaded from the data source.

Since
100.12

◆ 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

◆ selectedFeaturesWithCompletion:

- (id<AGSCancelable>) selectedFeaturesWithCompletion: (void(^)(AGSFeatureQueryResult *__nullable result, NSError *__nullable error))  completion

Finds a list of the currently selected features.

Parameters
completionA block that is invoked when the operation finishes. The result parameter is populated if the operation completed successfully, otherwise the error parameter is populated.
Returns
An operation which can be canceled.
Since
100.12

◆ selectFeature:

- (void) selectFeature: (AGSFeature *)  feature

Selects the given feature and adds it to the current list of selected features.

Parameters
featureThe feature.
Since
100.12

◆ selectFeatures:

- (void) selectFeatures: (NSArray< AGSFeature * > *)  features

Selects the features in the list and adds them to the current list of selected features.

Parameters
featuresAn NSArray of type AGSFeature. Contents of the NSArray are copied.
Since
100.12

◆ selectFeaturesWithParameters:mode:completion:

- (id<AGSCancelable>) selectFeaturesWithParameters: (AGSQueryParameters *)  parameters
mode: (AGSSelectionMode mode
completion: (void(^)(AGSFeatureQueryResult *__nullable result, NSError *__nullable error))  completion 

Selects the features that match the criteria in the AGSQueryParameters object and adds them to the current list of selected features.

Parameters
parametersThe definition of the query to submit to the feature table.
modeThe mode that defines how the list of currently selected features will be updated with the features returned from the query.
completionA block that is invoked when the operation finishes. The result parameter is populated if the operation completed successfully, otherwise the error parameter is populated.
Returns
An operation which can be canceled.
Since
100.12

◆ setFeature:visible:

- (void) setFeature: (AGSFeature *)  feature
visible: (BOOL)  visible 

Sets the visibility of the given feature.

Parameters
featureThe feature.
visibleYES to show, NO to hide.
Since
100.12

◆ setFeatures:visible:

- (void) setFeatures: (NSArray< AGSFeature * > *)  features
visible: (BOOL)  visible 

Sets the visibility of the given features.

Parameters
featuresAn NSArray of type AGSFeature. Contents of the NSArray are copied.
visibleYES to show, NO to hide.
Since
100.12

◆ unselectFeature:

- (void) unselectFeature: (AGSFeature *)  feature

Unselects the given feature and removes it from the current list of selected features.

Parameters
featureThe feature.
Since
100.12

◆ unselectFeatures:

- (void) unselectFeatures: (NSArray< AGSFeature * > *)  features

Unselects the features in the given list and removes them from the current list of selected features.

Parameters
featuresAn NSArray of type AGSFeature. Contents of the NSArray are copied.
Since
100.12

Property Documentation

◆ attribution

- (NSString*) attribution
readnonatomiccopyinherited

Attribution information of the layer.

Since
100

◆ barrierWeight

- (AGSLabelBarrierWeight) barrierWeight
readwritenonatomicassign

The weight of annotation features when considered as barriers to labeling. The default is AGSLabelBarrierWeightHigh.

Since
100.14

◆ canChangeVisibility

- (BOOL) canChangeVisibility
readrequirednonatomicassigninherited

Denotes whether the layer can change visibility or not.

Since
100

◆ credential

- (AGSCredential*) credential
readwritenonatomicstronginherited

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

Since
100

◆ definitionExpression

- (NSString*) definitionExpression
readwritenonatomiccopy

An expression which is a SQL statement where clause to specify the subset of features to be displayed.

The definition expression string uses the SQL-92 where clause syntax (https://en.wikipedia.org/wiki/SQL-92). The default value is an empty string, which will allow all annotation features in the data source to be used by the AGSAnnotationLayer.

Warning
: Be sure to escape special characters in the expression string as required for your platform. The DATE keyword expects the date format yyyy-mm-dd and the TIMESTAMP keyword expects the time stamp format yyyy-mm-dd hh:mm:ss. See the ArcGIS Blog article entitled "Querying Feature Services Date-Time Queries" (https://www.esri.com/arcgis-blog/products/api-rest/data-management/querying-feature-services-date-time-queries/) for more information.
Since
100.12

◆ featureTable

- (AGSArcGISFeatureTable*) featureTable
readnonatomicstrong

The feature table associated with this layer.

Since
100.6

◆ fullExtent

- (AGSEnvelope*) fullExtent
readnonatomicstronginherited

Full extent of the layer.

Since
100

◆ identifyEnabled

- (BOOL) identifyEnabled
readnonatomicassigninherited

Specifies whether the layer supports identify.

Since
100

◆ item

- (AGSItem*) item
readnonatomicstronginherited

The item the layer has been created from.

Since
100

◆ layerDescription

- (NSString*) layerDescription
readwritenonatomiccopyinherited

The layer's description.

Since
100

◆ layerID

- (NSString*) layerID
readwritenonatomiccopyinherited

The layer's ID specified in the web map item of ArcGIS Online or an on-premises portal.

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

◆ maxScale

- (double) maxScale
readwritenonatomicassigninherited

The maximum scale at which this layer is visible. If the map or scene is zoomed in beyond this scale, the layer will not be visible. A value of 0 means there is no maximum scale threshold and the layer will be visible at the smallest scale available for the map or scene.

Since
100

◆ minScale

- (double) minScale
readwritenonatomicassigninherited

The minimum scale at which this layer is visible. If the map or scene is zoomed out. beyond this scale, the layer will not be visible. A value of 0 means there is no minimum scale threshold and the layer will be visible at the largest scale available for the map or scene.

Since
100

◆ name

- (NSString*) name
readwritenonatomiccopyinherited

The name of the layer.

Since
100

◆ opacity

- (float) opacity
readwritenonatomicassigninherited

The opacity of this layer as a value between 0 (fully transparent) and 1 (fully opaque). Default value is 1.

Since
100

◆ referenceScale

- (double) referenceScale
readnonatomicassign

The reference scale for the layer. The reference scale of the layer is the scale at which a client should view the layer for the text to appear at its authored size.

If the client changes the viewing scale, then text will grow or shrink to keep a consistent size on the map (not the screen).

For a valid layer, the reference scale will always be a finite value, greater than zero. Until the layer is loaded, the reference scale will be zero.

Since
100.5

◆ 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

◆ serviceLayerID

- (NSInteger) serviceLayerID
readnonatomicassign

The layer ID that defines the layer within the feature service portal item.

See also
AGSLayer::item
Since
100.5

◆ showInLegend

- (BOOL) showInLegend
readwritenonatomicassigninherited

Indicates whether to show legend information.

Since
100

◆ spatialReference

- (AGSSpatialReference*) spatialReference
readnonatomicstronginherited

The spatial reference of the layer.

Since
100

◆ subLayerContents

- (NSArray<id<AGSLayerContent> >*) subLayerContents
readnonatomiccopyinherited

This layer's sub-layers.

Since
100

◆ subLayerContentsChangedHandler

- (void(^ subLayerContentsChangedHandler) (void))
readwritenonatomiccopyinherited

Block that is invoked when the sub layer contents changes.

Note
The block will be invoked on the same thread on which the event occurred, which could be any arbitrary thread. You need to dispatch any UI related work to the main thread.
Since
100

◆ URL

- (NSURL*) URL
readrequirednonatomicstronginherited

The URL of the remote resource.

Since
100

◆ visible

- (BOOL) visible
readwritenonatomicassigninherited

Denotes whether the layer is visible or not. The visibility changes can be monitored using Key-Value Observing (KVO).

Since
100