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 Terrain-RGB data.
To display posterized hillshading based on vector shapes, as with the MapTiler 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)
}
-initWithIdentifier:source:
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.
Accessing the Paint Attributes
hillshadeAccentColor
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 UIColor.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
UIColor
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, assign, unsafe_unretained, readwrite, null_resettable)
NSExpression *hillshadeAccentColor;
Swift
var hillshadeAccentColor: NSExpression! { get set }
hillshadeAccentColorTransition
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, assign, unsafe_unretained, readwrite)
MGLTransition hillshadeAccentColorTransition;
Swift
var hillshadeAccentColorTransition: MGLTransition { get set }
hillshadeExaggeration
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, assign, unsafe_unretained, readwrite, null_resettable)
NSExpression *hillshadeExaggeration;
Swift
var hillshadeExaggeration: NSExpression! { get set }
hillshadeExaggerationTransition
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, assign, unsafe_unretained, readwrite)
MGLTransition hillshadeExaggerationTransition;
Swift
var hillshadeExaggerationTransition: MGLTransition { get set }
hillshadeHighlightColor
The shading color of areas that faces towards the light source.
The default value of this property is an expression that evaluates to UIColor.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
UIColor
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, assign, unsafe_unretained, readwrite, null_resettable)
NSExpression *hillshadeHighlightColor;
Swift
var hillshadeHighlightColor: NSExpression! { get set }
hillshadeHighlightColorTransition
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, assign, unsafe_unretained, readwrite)
MGLTransition hillshadeHighlightColorTransition;
Swift
var hillshadeHighlightColorTransition: MGLTransition { get set }
hillshadeIlluminationAnchor
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, assign, unsafe_unretained, readwrite, null_resettable)
NSExpression *hillshadeIlluminationAnchor;
Swift
var hillshadeIlluminationAnchor: NSExpression! { get set }
hillshadeIlluminationDirection
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, assign, unsafe_unretained, readwrite, null_resettable)
NSExpression *hillshadeIlluminationDirection;
Swift
var hillshadeIlluminationDirection: NSExpression! { get set }
hillshadeShadowColor
The shading color of areas that face away from the light source.
The default value of this property is an expression that evaluates to UIColor.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
UIColor
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, assign, unsafe_unretained, readwrite, null_resettable)
NSExpression *hillshadeShadowColor;
Swift
var hillshadeShadowColor: NSExpression! { get set }
hillshadeShadowColorTransition
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, assign, unsafe_unretained, readwrite)
MGLTransition hillshadeShadowColorTransition;
Swift
var hillshadeShadowColorTransition: MGLTransition { get set }
iOS SDK
Examples
SDK JS Reference
- Annotations
- Appendices
- NSExpression(MGLAdditions)
- NSValue(MGLAdditions)
- NSValue(MGLCircleStyleLayerAdditions)
- NSValue(MGLFillExtrusionStyleLayerAdditions)
- NSValue(MGLFillStyleLayerAdditions)
- NSValue(MGLHillshadeStyleLayerAdditions)
- NSValue(MGLLineStyleLayerAdditions)
- NSValue(MGLRasterStyleLayerAdditions)
- NSValue(MGLSymbolStyleLayerAdditions)
- MGLAccountManager
- MGLAnnotationImage
- MGLAnnotationView
- MGLAttributedExpression
- MGLAttributionInfo
- MGLBackgroundStyleLayer
- MGLCircleStyleLayer
- MGLClockDirectionFormatter
- MGLCompassButton
- MGLCompassDirectionFormatter
- MGLComputedShapeSource
- MGLCoordinateFormatter
- MGLDistanceFormatter
- MGLFillExtrusionStyleLayer
- MGLFillStyleLayer
- MGLForegroundStyleLayer
- MGLHeatmapStyleLayer
- MGLHillshadeStyleLayer
- MGLImageSource
- MGLLight
- MGLLineStyleLayer
- MGLLoggingConfiguration
- MGLMapCamera
- MGLMapSnapshot
- MGLMapSnapshotOptions
- MGLMapSnapshotOverlay
- MGLMapSnapshotter
- MGLMapView
- MGLMultiPoint
- MGLMultiPolygon
- MGLMultiPolyline
- MGLNetworkConfiguration
- MGLOfflinePack
- MGLOfflineStorage
- MGLPointAnnotation
- MGLPointCollection
- MGLPolygon
- MGLPolyline
- MGLRasterStyleLayer
- MGLRasterTileSource
- MGLShape
- MGLShapeCollection
- MGLShapeOfflineRegion
- MGLShapeSource
- MGLSource
- MGLStyle
- MGLStyleLayer
- MGLSymbolStyleLayer
- MGLTilePyramidOfflineRegion
- MGLTileSource
- MGLUserLocation
- MGLUserLocationAnnotationView
- MGLUserLocationAnnotationViewStyle
- MGLVectorStyleLayer
- MGLVectorTileSource
- MGLAnnotationVerticalAlignment
- MGLAnnotationViewDragState
- MGLAttributionInfoStyle
- MGLCirclePitchAlignment
- MGLCircleScaleAlignment
- MGLCircleTranslationAnchor
- MGLDEMEncoding
- MGLErrorCode
- MGLFillExtrusionTranslationAnchor
- MGLFillTranslationAnchor
- MGLHillshadeIlluminationAnchor
- MGLIconAnchor
- MGLIconPitchAlignment
- MGLIconRotationAlignment
- MGLIconTextFit
- MGLIconTranslationAnchor
- MGLLightAnchor
- MGLLineCap
- MGLLineJoin
- MGLLineTranslationAnchor
- MGLLoggingLevel
- MGLMapDebugMaskOptions
- MGLOfflinePackState
- MGLOrnamentPosition
- MGLOrnamentVisibility
- MGLRasterResamplingMode
- MGLResourceKind
- MGLSymbolPlacement
- MGLSymbolZOrder
- MGLTextAnchor
- MGLTextJustification
- MGLTextPitchAlignment
- MGLTextRotationAlignment
- MGLTextTransform
- MGLTextTranslationAnchor
- MGLTextWritingMode
- MGLTileCoordinateSystem
- MGLUserTrackingMode
- Formatters
- Geometry
- Location Updates
- Maps
- Offline Maps
- Other Categories
- Other Classes
- Other Constants
- Other Enumerations
- Other Functions
- Other Protocols
- Other Structures
- Other Type Definitions
- Primitive Shapes
- MGLAnnotation
- MGLCalloutView
- MGLCalloutViewDelegate
- MGLCluster
- MGLComputedShapeSourceDataSource
- MGLFeature
- MGLLocationManager
- MGLLocationManagerDelegate
- MGLMapSnapshotterDelegate
- MGLMapViewDelegate
- MGLOfflineRegion
- MGLOfflineStorageDelegate
- MGLOverlay
- MGLStylable
- MGLCoordinateBounds
- MGLCoordinateQuad
- MGLCoordinateSpan
- MGLOfflinePackProgress
- MGLSphericalPosition
- MGLTransition
- Style Content
- Style Layers
- Style Primitives
- Styling the Map
- MGLCoordinateBounds
- MGLCoordinateQuad
- MGLCoordinateSpan
- MGLOfflinePackProgress
- MGLSphericalPosition
- MGLTransition
- User Interaction
- Customizing Fonts
- Information for Style Authors
- Gesture Recognizers
- Info.plist Keys
- Migrating to Expressions
- Predicates and expressions
- Tile URL Templates
- Working with GeoJSON Data