TranslucentMapLayerGroup
public class TranslucentMapLayerGroup
extension TranslucentMapLayerGroup: NativeBase
extension TranslucentMapLayerGroup: Hashable
A translucent layer group that can be the target for MapLayerPriorityBuilder.inGroup(...).
Currently, only custom line layers can be added to a translucent layer group.
Custom line layers in a translucent layer group are rendered in an offscreen translucent pass so
that overlapping translucent line geometry is not alpha blended with itself.
At creation, the layer group gets added to a map. The layer group gets removed from the map upon
instance destruction and any layer (categories) still in the group are not rendered anymore,
therefore it is recommended to keep a group alive as long as layers using the group are alive and
in use.
Conceptual example to place line layers into a translucent group:
// Create a translucent group with a unique name and a render priority
let groupPriority = MapLayerPriorityBuilder().renderedLast().build()
let group = TranslucentMapLayerGroup(name: "TranslucentGroupName", map, groupPriority)
// Create a line layer to be rendered as part of the translucent group
let lineLayerPriority = MapLayerPriorityBuilder()
.inGroup("TranslucentGroupName") // places the line layer into the group
.renderedFirst() // to be rendered first when the group is rendered
.withCategory("SomeCategory") // places the line layer category 'SomeCategory'
.inGroup("TranslucentGroupName") // into the group
.renderedLast() // to be rendered last when the group is rendered
.build()
let lineLayer = MapLayerBuilder()
.withDataSource(named: "DataSourceName", contentType: MapContentType.line)
.forMap(map)
.withName("LineLayerName")
.withPriority(lineLayerPriority)
.withStyle(translucentLineStyle) // E.g. "technique": "line" ... "color": "#FFFFFF80"
.build()
// Create a second line layer to be rendered as part of the translucent group
let secondLineLayerPriority = MapLayerPriorityBuilder()
.inGroup("TranslucentGroupName") // places the second line layer into the group
.renderedBeforeLayer("LineLayerName") // to be rendered before first layer
// when the group is rendered
.build()
let secondLineLayer = MapLayerBuilder()
.withDataSource(named: "SecondDataSourceName", contentType: MapContentType.line)
.forMap(map)
.withName("SecondLineLayerName")
.withPriority(secondLineLayerPriority)
.withStyle(secondTranslucentLineStyle) // E.g. "technique": "line" ... "color": "#FFFFFF80"
.build()
Note: This is a beta release of this feature, so there could be a few bugs and unexpected behavior. Related APIs may change for new releases without a deprecation process.
-
Thrown when failing to build the group.
Declaration
Swift
public typealias InstantiationError = TranslucentMapLayerGroup.ErrorDetails -
Creates an instance of the group.
Throws
TranslucentMapLayerGroup.InstantiationErrorIn case of invalid input parameters.Declaration
Swift
public init(name: String, aMap: HereMap) throwsParameters
nameName of the group. Must be unique across
MapLayerandTranslucentMapLayerGroup.aMapThe map to attach the group to.
-
Creates an instance of the group.
Throws
TranslucentMapLayerGroup.InstantiationErrorIn case of invalid input parameters.Declaration
Swift
public init(name: String, aMap: HereMap, _ priority: MapLayerPriority) throwsParameters
nameName of the group. Must be unique across
MapLayerandTranslucentMapLayerGroup.aMapThe map to attach the group to.
priorityThe
MapLayerPrioritywhich should be applied to position the group. TheMapLayerPrioritymust contain only one priority and this priority must have no category and no group, i.e.MapLayerPriorityBuilder.inGroup(...)andMapLayerPriorityBuilder.withCategory(...)should not be used when building theMapLayerPriority. Example: -
Error codes for creating the group.
See moreDeclaration
Swift
public enum ErrorCode : UInt32, CaseIterable, Codable -
Describes the reason for failing to create the group.
See moreDeclaration
-
Sets the render priority for the layer group which replaces any previously defined priority.
Declaration
Swift
public func setPriority(_ priority: MapLayerPriority)Parameters
priorityThe priority to position the group. The
MapLayerPrioritymust contain only one priority and this priority must have no category and no group, i.e.MapLayerPriorityBuilder.inGroup(...)andMapLayerPriorityBuilder.withCategory(...)should not be used when building theMapLayerPriority. Example:new MapLayerPriorityBuilder().renderedAfterLayer(“water”).build()
MapLayerPriorityBuilder().renderedAfterLayer(named: "water").build()