Class TranslucentMapLayerGroup


  • public final class TranslucentMapLayerGroup
    extends NativeBase

    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.