Legend

fun Legend(    operationalLayers: List<LayerContent>,     basemap: Basemap?,     currentScale: Double,     modifier: Modifier = Modifier,     reverseLayerOrder: Boolean = false,     respectScaleRange: Boolean = true,     title: String = stringResource(R.string.title),     typography: Typography = LegendDefaults.typography())

A composable that displays a legend for the given operational layers and basemap. The legend will display the layer symbology and description so users can better understand what is being viewed in the GeoView. The component provides the option to show all layers or only those layers in the current scale range of the GeoView as well as the ability to reverse the order of items in the legend. The legend will display information from layers, sublayers and group layers.

The required parameters are the operational layers, the basemap to display in the legend and the current scale of the GeoView. The currentScale can be obtained from the Composable MapView's onViewpointChangedForCenterAndScale callback.

Workflow example:

fun MainScreen(viewModel: LegendViewModel = viewModel()) {

    val loadState by viewModel.arcGISMap.loadStatus.collectAsState()
    val basemap = viewModel.arcGISMap.basemap.collectAsState()
    var currentScale: Double by remember { mutableDoubleStateOf(Double.NaN) }
    ...

    // show composable MapView with a legend in the bottom sheet
     BottomSheetScaffold(
        sheetContent = {
            AnimatedVisibility(
                visible = loadState is LoadStatus.Loaded,
                ...
            ) {
                Legend(
                    operationalLayers = viewModel.arcGISMap.operationalLayers,
                    basemap = basemap.value,
                    currentScale = currentScale,
                    modifier = Modifier.fillMaxSize()
                )
            }
        },
        modifier = Modifier.fillMaxSize(),
        scaffoldState = scaffoldState,
        sheetSwipeEnabled = true,
        topBar = null
    ) { padding ->
        MapView(
            modifier = Modifier
                .padding(padding)
                .fillMaxSize(),
            arcGISMap = viewModel.arcGISMap,
            onMapScaleChanged = { scale ->
                currentScale = scale
            }
        )
    }

Since

200.7.0

Parameters

operationalLayers

The operational layers to display in the legend.

basemap

The basemap to display in the legend.

currentScale

The current scale of the GeoView.

modifier

Modifier to be applied to the legend.

reverseLayerOrder

Whether to reverse the order of the layers in the legend.

respectScaleRange

Whether to respect the scale range of the layers.

title

The title of the legend. Defaults to "Legend". Empty string will not display the title.

typography

The typography to use for the legend.