Legend
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
The operational layers to display in the legend.
The basemap to display in the legend.
The current scale of the GeoView.
Modifier to be applied to the legend.
Whether to reverse the order of the layers in the legend.
Whether to respect the scale range of the layers.
The title of the legend. Defaults to "Legend". Empty string will not display the title.
The typography to use for the legend.