TranslucentMapLayerGroup (API Reference)
Class TranslucentMapLayerGroup
A translucent layer group that can be the target for MapLayerPriorityBuilder.inGroup(java.lang.String).
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
MapLayerPriority groupPriority = new MapLayerPriorityBuilder().renderedLast().build();
TranslucentMapLayerGroup group = new TranslucentMapLayerGroup("TranslucentGroupName", map, groupPriority)
// Create a line layer to be rendered as part of the translucent group
MapLayerPriority lineLayerPriority = new 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();
MapLayer lineLayer = new MapLayerBuilder()
.withDataSource("DataSourceName", 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
MapLayerPriority secondLineLayerPriority = new 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();
MapLayer secondLineLayer = new MapLayerBuilder()
.withDataSource("SecondDataSourceName", 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumError codes for creating the group.static final classDescribes the reason for failing to create the group.static final classThrown when failing to build the group. -
Constructor Summary
ConstructorsConstructorDescriptionTranslucentMapLayerGroup(String name, HereMap aMap) Creates an instance of the group.TranslucentMapLayerGroup(String name, HereMap aMap, MapLayerPriority priority) Creates an instance of the group. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Frees all internally used resources.voidsetPriority(MapLayerPriority priority) Sets the render priority for the layer group which replaces any previously defined priority.
-
Constructor Details
-
TranslucentMapLayerGroup
public TranslucentMapLayerGroup(@NonNull String name, @NonNull HereMap aMap) throws TranslucentMapLayerGroup.InstantiationException Creates an instance of the group.
- Parameters:
name-Name of the group. Must be unique across
MapLayerandTranslucentMapLayerGroup.aMap-The map to attach the group to.
- Throws:
TranslucentMapLayerGroup.InstantiationException-In case of invalid input parameters.
-
TranslucentMapLayerGroup
public TranslucentMapLayerGroup(@NonNull String name, @NonNull HereMap aMap, @NonNull MapLayerPriority priority) throws TranslucentMapLayerGroup.InstantiationException Creates an instance of the group.
- Parameters:
name-Name of the group. Must be unique across
MapLayerandTranslucentMapLayerGroup.aMap-The map to attach the group to.
priority-The
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(java.lang.String)andMapLayerPriorityBuilder.withCategory(java.lang.String)should not be used when building theMapLayerPriority. Example:new MapLayerPriorityBuilder().renderedAfterLayer("water").build()- Throws:
TranslucentMapLayerGroup.InstantiationException-In case of invalid input parameters.
-
-
Method Details
-
setPriority
Sets the render priority for the layer group which replaces any previously defined priority.
- Parameters:
priority-The 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(java.lang.String)andMapLayerPriorityBuilder.withCategory(java.lang.String)should not be used when building theMapLayerPriority. Example:new MapLayerPriorityBuilder().renderedAfterLayer("water").build()
-
destroy
public void destroy()Frees all internally used resources. After calling this method, the object is not usable anymore.
-