MGLStyleValue

@interface MGLStyleValue <T> : NSObject

An MGLStyleValue object is a generic container for a style attribute value. The layout and paint attribute properties of MGLStyleLayer can be set to MGLStyleValue objects.

The MGLStyleValue class itself represents a class cluster. Under the hood, a particular MGLStyleValue object may be either an MGLStyleConstantValue to represent a constant value or an MGLStyleFunction to represent a value function. Do not initialize an MGLStyleValue object directly; instead, use one of the class factory methods to create an MGLStyleValue object.

The MGLStyleValue class takes a generic parameter T that indicates the Foundation class being wrapped by this class. Common values for T include:

  • `NSNumber` (for Boolean values, floating-point numbers, and enumerations)
  • `NSValue` (for `CGVector`, `NSEdgeInset`, and `UIEdgeInset`s)
  • `NSString`
  • `NSColor` or `UIColor`
  • `NSArray`
  • Creates and returns an MGLStyleConstantValue object containing a raw value.

    Declaration

    Objective-C

    + (nonnull instancetype)valueWithRawValue:(nonnull T)rawValue;

    Swift

    convenience init(rawValue: T)

    Parameters

    rawValue

    The constant value contained by the object.

    Return Value

    An MGLStyleConstantValue object containing rawValue, which is treated as a constant value.

  • Creates and returns an MGLStyleFunction object representing a linear zoom level function with any number of stops.

    Declaration

    Objective-C

    + (nonnull instancetype)valueWithStops:
        (nonnull NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops;

    Swift

    convenience init(stops: [NSNumber : MGLStyleValue

    Parameters

    stops

    A dictionary associating zoom levels with style values.

    Return Value

    An MGLStyleFunction object with the given stops.

  • Creates and returns an MGLStyleFunction object representing a zoom level function with an exponential base and any number of stops.

    Declaration

    Objective-C

    + (nonnull instancetype)
    valueWithBase:(CGFloat)base
            stops:(nonnull NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops;

    Swift

    convenience init(base: CGFloat, stops: [NSNumber : MGLStyleValue

    Parameters

    base

    The exponential base of the interpolation curve.

    stops

    A dictionary associating zoom levels with style values.

    Return Value

    An MGLStyleFunction object with the given base and stops.