Scalebar

fun Scalebar(    maxWidth: Dp,     unitsPerDip: Double,     viewpoint: Viewpoint?,     spatialReference: SpatialReference?,     modifier: Modifier = Modifier,     autoHideDelay: Duration = Duration.INFINITE,     minScale: Double = 0.0,     useGeodeticCalculations: Boolean = true,     style: ScalebarStyle = ScalebarStyle.AlternatingBar,     units: UnitSystem = rememberDefaultUnitSystem(),     colorScheme: ScalebarColors = ScalebarDefaults.colors(),     shapes: ScalebarShapes = ScalebarDefaults.shapes(),     labelTypography: LabelTypography = ScalebarDefaults.typography())

A composable UI component to display a Scalebar. A Scalebar displays the representation of an accurate linear measurement on the map. It provides a visual indication through which users can determine the size of features or the distance between features on a map.

The required parameters to display a Scalebar are the maximum width of the Scalebar in device independent pixels (dp), the current unitsPerDip of the MapView, and the current ViewpointType.CenterAndScale of the MapView and the SpatialReference of the MapView. The current value of unitsPerDip can be obtained from the Composable MapView's onUnitsPerDipChanged callback. The Viewpoint can be obtained from the Composable MapView's onViewpointChangedForCenterAndScale callback and the SpatialReference can be obtained from the Composable MapView's onSpatialReferenceChanged callback.

The Scalebar will be automatically updated when the Viewpoint changes.

Workflow example:

    var viewpoint: Viewpoint? by remember { mutableStateOf(null) }
    var unitsPerDip by remember { mutableDoubleStateOf(Double.NaN) }
    var spatialReference: SpatialReference? by remember { mutableStateOf(null) }
    // show composable MapView with a Scalebar
    Box(
        modifier = modifier.fillMaxSize()
    ) {
        MapView(
            modifier = Modifier.fillMaxSize(),
            arcGISMap = arcGISMap,
            onSpatialReferenceChanged = { spatialReference = it },
            onUnitsPerDipChanged = { unitsPerDip = it },
            onViewpointChangedForCenterAndScale = { viewpoint = it }
        )
        Scalebar(
            modifier = Modifier
                .padding(25.dp)
                .align(Alignment.BottomStart),
            maxWidth = 175.dp,
            unitsPerDip = unitsPerDip,
            viewpoint = viewpoint,
            spatialReference = spatialReference,
        )
    }

Since

200.7.0

Parameters

maxWidth

the maximum screen width allotted to the scalebar in dp.

unitsPerDip

the number of map units per density-independent pixel (dp).

viewpoint

the current viewpoint of the map.

spatialReference

the spatial reference of the map.

modifier

the modifier to apply to this layout.

autoHideDelay

the duration to wait before hiding the scalebar, set to Duration.INFINITE to disable auto-hide.

minScale

the minimum scale to show the scalebar, default is 0.0 which means the scalebar will always be visible.

useGeodeticCalculations

true to compute scale using a geodesic curve, falseotherwise, default is true.

style

the style of the scalebar, default is ScalebarStyle.AlternatingBar.

units

the units for the scalebar, default is the default unit system based on the device's locale.

colorScheme

the color scheme for the scalebar.

shapes

the shapes for the scalebar.

labelTypography

the typography for the scalebar labels.