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

Description

Defines how labels should be displayed.

An instance of this class specifies how labels should be displayed for features in a layer or for graphics in a graphics overlay within a specific scale range. It can specify -

  • which features/graphics are covered by the definition (by applying the label definition's where-clause)
  • what text should be displayed, based on the individual attributes of the feature/graphic and the label definition label-expression formula
  • how the text should appear, using the definition's text symbol
  • where the text should appear, with respect to its feature/graphic, using the definition's label placement
  • how to move or avoid other labels and features/graphics that would overlap each label

An instance of AGSLabelDefinition can be constructed from JSON as follows :

let labelDefinitionString = "{"
+ " \"allowOverrun\": false,"
+ " \"deconflictionStrategy\":\"static\","
+ " \"labelExpressionInfo\": { \"expression\": \"round($feature.length,2) + 'm^2'\"},"
+ " \"labelPlacement\": \"esriServerPolygonPlacementAlwaysHorizontal\","
+ " \"lineConnection\": \"none\","
+ " \"minScale\": 1999,"
+ " \"maxScale\": 0,"
+ " \"multiPart\": \"labelLargest\","
+ " \"name\":\"Building interior code\","
+ " \"priority\": 15,"
+ " \"removeDuplicates\": \"featureType\","
+ " \"removeDuplicatesDistance\": 300,"
+ " \"repeatLabel\":false,"
+ " \"repeatLabelDistance\":0,"
+ " \"stackLabel\": true,"
+ " \"stackAlignment\": \"dynamic\","
+ " \"stackRowLength\": 20,"
+ " \"stackBreakPosition\": \"before\","
+ " \"symbol\": {\"type\": \"esriTS\", \"color\": [0,78,78,255], \"backgroundColor\": null, \"borderLineColor\": null, \"verticalAlignment\": \"bottom\", \"horizontalAlignment\": \"left\", \"rightToLeft\": false, \"angle\": 0, \"xoffset\": 0, \"yoffset\": 0, \"font\": {\"family\": \"Arial\", \"size\": 12, \"style\": \"normal\", \"weight\": \"bold\", \"decoration\": \"none\"}},"
+ "}"
if let jsonData = labelDefinitionString.data(using: .utf8) {
do {
//convert string data into JSON
let JSON = try JSONSerialization.jsonObject(with: jsonData, options: JSONSerialization.ReadingOptions.mutableContainers)
//convert JSON into AGSLabelDefinition
let labelDefinition = try AGSLabelDefinition.fromJSON(JSON)
}
catch {
print("Error: \(error.localizedDescription)")
}
}
Since
100.1
See also
AGSFeatureLayer::labelsEnabled, AGSGraphicsOverlay::labelsEnabled, AGSArcGISMapImageSublayer::labelsEnabled to enable labels
AGSFeatureLayer::labelDefinitions, AGSGraphicsOverlay::labelDefinitions, AGSArcGISMapImageSublayer::labelDefinitions to specify label definitions
Inheritance diagram for AGSLabelDefinition:
AGSObject <AGSJSONSerializable>

Instance Methods

(nullable id) - toJSON:
 

Class Methods

(nullable id< AGSJSONSerializable >) + fromJSON:error:
 

Properties

NSDictionary< NSString *, id > * unknownJSON
 
NSDictionary< NSString *, id > * unsupportedJSON
 

Method Documentation

§ fromJSON:error:()

+ (nullable id<AGSJSONSerializable>) fromJSON: (id)  JSONObject
error: (NSError **)  error 
staticrequiredinherited

Initializes and returns an object from its JSON representation.

Parameters
JSONObjectNSDictionary or NSArray containing the JSON.
errorencountered during the operation, if any.
Since
100

§ toJSON:()

- (nullable id) toJSON: (NSError **)  error
requiredinherited

Returns JSON representation for this object.

Parameters
errorencountered during the operation, if any.
Returns
NSDictionary or NSArray containing the JSON.
Since
100

Reimplemented in AGSPortalItem.

Property Documentation

§ unknownJSON

- (NSDictionary<NSString*,id>*) unknownJSON
readrequirednonatomiccopyinherited

A dictionary of values that was in the source JSON but was unparsed by API.

Returns
NSDictionary containing the unknown JSON.
Since
100

§ unsupportedJSON

- (NSDictionary<NSString*,id>*) unsupportedJSON
readnonatomiccopyinherited

A dictionary of values that are supported by the REST API, but not exposed through the SDK API.

Returns
NSDictionary containing the unsupported JSON.
Since
100