Scalebar
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
the maximum screen width allotted to the scalebar in dp.
the number of map units per density-independent pixel (dp).
the current viewpoint of the map.
the spatial reference of the map.
the modifier to apply to this layout.
the duration to wait before hiding the scalebar, set to Duration.INFINITE
to disable auto-hide.
the minimum scale to show the scalebar, default is 0.0
which means the scalebar will always be visible.
true
to compute scale using a geodesic curve, false
otherwise, default is true
.
the style of the scalebar, default is ScalebarStyle.AlternatingBar.
the units for the scalebar, default is the default unit system based on the device's locale.
the color scheme for the scalebar.
the shapes for the scalebar.
the typography for the scalebar labels.