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 MGLConstantStyleValue to represent a constant value or one of the concrete subclasses of 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 and floating-point numbers)
  • NSValue (for CGVector, NSEdgeInsets, UIEdgeInsets, and enumerations)
  • NSString
  • NSColor or UIColor
  • NSArray
  • Creates and returns an MGLCameraStyleFunction object representing a linear camera function with one or more stops.

    Declaration

    Objective-C

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

    Swift

    convenience init(stops: [NSNumber : MGLStyleValue<T>])

    Parameters

    stops

    A dictionary associating zoom levels with style values.

    Return Value

    An MGLCameraStyleFunction object with the given stops.

  • Creates and returns an MGLCameraStyleFunction object representing a camera function with an exponential interpolation base and one or more stops.

    Declaration

    Objective-C

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

    Swift

    convenience init(interpolationBase: CGFloat, stops: [NSNumber : MGLStyleValue<T>])

    Parameters

    interpolationBase

    The exponential base of the interpolation curve.

    stops

    A dictionary associating zoom levels with style values.

    Return Value

    An MGLCameraStyleFunction object with the given interpolation base and stops.

  • Creates and returns an MGLCameraStyleFunction object representing a camera function with one or more stops.

    Declaration

    Objective-C

    + (nonnull instancetype)
    valueWithInterpolationMode:(MGLInterpolationMode)interpolationMode
                   cameraStops:
                       (nonnull NSDictionary<id, MGLStyleValue<T> *> *)cameraStops
                       options:(nullable NSDictionary<MGLStyleFunctionOption, id> *)
                                   options;

    Swift

    convenience init(interpolationMode: MGLInterpolationMode, cameraStops: [AnyHashable : MGLStyleValue<T>], options: [MGLStyleFunctionOption : Any]? = nil)

    Parameters

    interpolationMode

    The mode used to interpolate property values between map zoom level changes.

    cameraStops

    A dictionary associating zoom levels with style values.

    options

    A dictionary containing MGLStyleFunctionOption values that specify how a function is applied.

    Return Value

    An MGLCameraStyleFunction object with the given interpolation mode, camera stops, and options.

  • Creates and returns an MGLSourceStyleFunction object representing a source function.

    Declaration

    Objective-C

    + (nonnull instancetype)
    valueWithInterpolationMode:(MGLInterpolationMode)interpolationMode
                   sourceStops:
                       (nullable NSDictionary<id, MGLStyleValue<T> *> *)sourceStops
                 attributeName:(nonnull NSString *)attributeName
                       options:(nullable NSDictionary<MGLStyleFunctionOption, id> *)
                                   options;

    Swift

    convenience init(interpolationMode: MGLInterpolationMode, sourceStops: [AnyHashable : MGLStyleValue<T>]?, attributeName: String, options: [MGLStyleFunctionOption : Any]? = nil)

    Parameters

    interpolationMode

    The mode used to interpolate property values over a range of feature attribute values.

    sourceStops

    A dictionary associating feature attributes with style values.

    attributeName

    Specifies the feature attribute to take as the function input.

    options

    A dictionary containing MGLStyleFunctionOption values that specify how a function is applied.

    Return Value

    An MGLSourceStyleFunction object with the given interpolation mode, source stops, attribute name, and options.

  • Creates and returns an MGLCompositeStyleFunction object representing a composite function.

    Declaration

    Objective-C

    + (nonnull instancetype)
    valueWithInterpolationMode:(MGLInterpolationMode)interpolationMode
                compositeStops:
                    (nonnull
                         NSDictionary<id, NSDictionary<id, MGLStyleValue<T> *> *> *)
                        compositeStops
                 attributeName:(nonnull NSString *)attributeName
                       options:(nullable NSDictionary<MGLStyleFunctionOption, id> *)
                                   options;

    Swift

    convenience init(interpolationMode: MGLInterpolationMode, compositeStops: [AnyHashable : [AnyHashable : MGLStyleValue<T>]], attributeName: String, options: [MGLStyleFunctionOption : Any]? = nil)

    Parameters

    interpolationMode

    The mode used to interpolate property values over a range of feature attribute values for each outer zoom level.

    compositeStops

    A dictionary associating feature attributes with style values.

    attributeName

    Specifies the feature attribute to take as the function input.

    options

    A dictionary containing MGLStyleFunctionOption values that specify how a function is applied.

    Return Value

    An MGLCompositeStyleFunction object with the given interpolation mode, composite stops, attribute name, and options.