MGLBackgroundStyleLayer
@interface MGLBackgroundStyleLayer : MGLStyleLayer
An MGLBackgroundStyleLayer
is a style layer that covers the entire map. Use a background style layer to configure a color or pattern to show below all other map content. If the style’s other layers use the MapTiler Streets source, the background style layer is responsible for drawing land, whereas the oceans and other bodies of water are drawn by MGLFillStyleLayer
objects.
A background style layer is typically the bottommost layer in a style, because it covers the entire map and can occlude any layers below it. You can therefore access it by getting the last item in the MGLStyle.layers
array.
If the background style layer is transparent or omitted from the style, any portion of the map view that does not show another style layer is transparent.
-initWithIdentifier:
Returns a background style layer initialized with an identifier.
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;
Swift
init(identifier: String)
Parameters
identifier
A string that uniquely identifies the source in the style to which it is added.
Accessing the Paint Attributes
backgroundColor
The color with which the background will be drawn.
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.
This property is only applied to the style if backgroundPattern
is set to nil
. Otherwise, it is ignored.
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 *backgroundColor;
Swift
var backgroundColor: NSExpression! { get set }
backgroundColorTransition
The transition affecting any changes to this layer’s backgroundColor
property.
This property corresponds to the background-color-transition
property in the style JSON file format.
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite)
MGLTransition backgroundColorTransition;
Swift
var backgroundColorTransition: MGLTransition { get set }
backgroundOpacity
The opacity at which the background will be drawn.
The default value of this property is an expression that evaluates to the float 1
. 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 *backgroundOpacity;
Swift
var backgroundOpacity: NSExpression! { get set }
backgroundOpacityTransition
The transition affecting any changes to this layer’s backgroundOpacity
property.
This property corresponds to the background-opacity-transition
property in the style JSON file format.
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite)
MGLTransition backgroundOpacityTransition;
Swift
var backgroundOpacityTransition: MGLTransition { get set }
backgroundPattern
Name of image in style images to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, …, 512).
You can set this property to an expression containing any of the following:
- Constant string values
- 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 *backgroundPattern;
Swift
var backgroundPattern: NSExpression! { get set }
backgroundPatternTransition
The transition affecting any changes to this layer’s backgroundPattern
property.
This property corresponds to the background-pattern-transition
property in the style JSON file format.
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite)
MGLTransition backgroundPatternTransition;
Swift
var backgroundPatternTransition: 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