MGLStyleFunction

@interface MGLStyleFunction <T> : MGLStyleValue

An MGLStyleFunction is a value function defining a style value that changes as the zoom level changes. The layout and paint attribute properties of an MGLStyleLayer object can be set to MGLStyleFunction objects. Use a zoom level function to create the illusion of depth and control data density.

The MGLStyleFunction class takes a generic parameter T that indicates the Foundation class being wrapped by this class.

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

    Declaration

    Objective-C

    + (nonnull instancetype)functionWithStops:
        (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)
    functionWithBase:(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.

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

    Declaration

    Objective-C

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

    Swift

    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.

  • The exponential base of the function’s interpolation curve.

    The exponential base controls the rate at which the function’s output values increase. A value of 1 causes the function to increase linearly by zoom level. A higher exponential base causes the function’s output values to vary exponentially, increasing more rapidly towards the high end of the function’s range. The default value of this property is 1, for a linear curve.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat base;

    Swift

    var base: CGFloat { get set }
  • A dictionary associating zoom levels with style values.

    Each of the function’s stops is represented by one key-value pair in the dictionary. Each key in the dictionary is an NSNumber object containing a floating-point zoom level. Each value in the dictionary is an MGLStyleValue object containing the value of the style attribute when the map is at the associated zoom level. An MGLStyleFunction object may not be used recursively as a stop value.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic)
        NSDictionary<NSNumber *, MGLStyleValue<T> *> *_Nonnull stops;

    Swift

    var stops: [NSNumber : MGLStyleValue