MGLHillshadeStyleLayer


@interface MGLHillshadeStyleLayer : MGLForegroundStyleLayer

An MGLHillshadeStyleLayer is a style layer that renders raster digital elevation model (DEM) tiles on the map.

Use a hillshade style layer to configure the color parameters of raster tiles loaded by an MGLRasterDEMSource object. For example, you could use a hillshade style layer to render Mapbox Terrain-RGB data.

To display posterized hillshading based on vector shapes, as with the Mapbox Terrain source, use an MGLVectorTileSource object in conjunction with several MGLFillStyleLayer objects.

You can access an existing hillshade style layer using the -[MGLStyle layerWithIdentifier:] method if you know its identifier; otherwise, find it using the MGLStyle.layers property. You can also create a new hillshade style layer and add it to the style using a method such as -[MGLStyle addLayer:].

Example

let layer = MGLHillshadeStyleLayer(identifier: "hills", source: source)
layer.hillshadeExaggeration = NSExpression(forConstantValue: 0.6)
if let canalShadowLayer = mapView.style?.layer(withIdentifier: "waterway-river-canal-shadow") {
    mapView.style?.insertLayer(layer, below: canalShadowLayer)
}
  • Returns a hillshade style layer initialized with an identifier and source.

    After initializing and configuring the style layer, add it to a map view’s style using the -[MGLStyle addLayer:] or -[MGLStyle insertLayer:belowLayer:] method.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithIdentifier:(nonnull NSString *)identifier
                                        source:(nonnull MGLSource *)source;

    Swift

    init(identifier: String, source: MGLSource)

    Parameters

    identifier

    A string that uniquely identifies the source in the style to which it is added.

    source

    The source from which to obtain the data to style. If the source has not yet been added to the current style, the behavior is undefined.

    Return Value

    An initialized foreground style layer.

  • The shading color used to accentuate rugged terrain like sharp cliffs and gorges.

    The default value of this property is an expression that evaluates to NSColor.blackColor. Set this property to nil to reset it to the default value.

    You can set this property to an expression containing any of the following:

    • Constant NSColor values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

    This property does not support applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *hillshadeAccentColor;

    Swift

    var hillshadeAccentColor: NSExpression! { get set }
  • The transition affecting any changes to this layer’s hillshadeAccentColor property.

    This property corresponds to the hillshade-accent-color-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition hillshadeAccentColorTransition;

    Swift

    var hillshadeAccentColorTransition: MGLTransition { get set }
  • Intensity of the hillshade

    The default value of this property is an expression that evaluates to the float 0.5. Set this property to nil to reset it to the default value.

    You can set this property to an expression containing any of the following:

    • Constant numeric values between 0 and 1 inclusive
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

    This property does not support applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *hillshadeExaggeration;

    Swift

    var hillshadeExaggeration: NSExpression! { get set }
  • The transition affecting any changes to this layer’s hillshadeExaggeration property.

    This property corresponds to the hillshade-exaggeration-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition hillshadeExaggerationTransition;

    Swift

    var hillshadeExaggerationTransition: MGLTransition { get set }
  • The shading color of areas that faces towards the light source.

    The default value of this property is an expression that evaluates to NSColor.whiteColor. Set this property to nil to reset it to the default value.

    You can set this property to an expression containing any of the following:

    • Constant NSColor values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

    This property does not support applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *hillshadeHighlightColor;

    Swift

    var hillshadeHighlightColor: NSExpression! { get set }
  • The transition affecting any changes to this layer’s hillshadeHighlightColor property.

    This property corresponds to the hillshade-highlight-color-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition hillshadeHighlightColorTransition;

    Swift

    var hillshadeHighlightColorTransition: MGLTransition { get set }
  • Direction of light source when map is rotated.

    The default value of this property is an expression that evaluates to viewport. Set this property to nil to reset it to the default value.

    You can set this property to an expression containing any of the following:

    • Constant MGLHillshadeIlluminationAnchor values
    • Any of the following constant string values:
      • map: The hillshade illumination is relative to the north direction.
      • viewport: The hillshade illumination is relative to the top of the viewport.
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *hillshadeIlluminationAnchor;

    Swift

    var hillshadeIlluminationAnchor: NSExpression! { get set }
  • The direction of the light source used to generate the hillshading with 0 as the top of the viewport if hillshadeIlluminationAnchor is set to MGLHillshadeIlluminationAnchorViewport and due north if hillshadeIlluminationAnchor is set to MGLHillshadeIlluminationAnchorMap.

    The default value of this property is an expression that evaluates to the float 335. Set this property to nil to reset it to the default value.

    You can set this property to an expression containing any of the following:

    • Constant numeric values between 0 and 359 inclusive
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

    This property does not support applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *hillshadeIlluminationDirection;

    Swift

    var hillshadeIlluminationDirection: NSExpression! { get set }
  • The shading color of areas that face away from the light source.

    The default value of this property is an expression that evaluates to NSColor.blackColor. Set this property to nil to reset it to the default value.

    You can set this property to an expression containing any of the following:

    • Constant NSColor values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

    This property does not support applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *hillshadeShadowColor;

    Swift

    var hillshadeShadowColor: NSExpression! { get set }
  • The transition affecting any changes to this layer’s hillshadeShadowColor property.

    This property corresponds to the hillshade-shadow-color-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition hillshadeShadowColorTransition;

    Swift

    var hillshadeShadowColorTransition: MGLTransition { get set }