|
17 | 17 |
|
18 | 18 | package com.arcgismaps.toolkit.geocompose
|
19 | 19 |
|
| 20 | +import androidx.compose.foundation.layout.Box |
20 | 21 | import androidx.compose.runtime.Composable
|
21 | 22 | import androidx.compose.runtime.DisposableEffect
|
22 | 23 | import androidx.compose.runtime.LaunchedEffect
|
23 | 24 | import androidx.compose.runtime.remember
|
24 | 25 | import androidx.compose.ui.Modifier
|
25 | 26 | import androidx.compose.ui.platform.LocalContext
|
26 | 27 | import androidx.compose.ui.platform.LocalLifecycleOwner
|
| 28 | +import androidx.compose.ui.semantics.contentDescription |
| 29 | +import androidx.compose.ui.semantics.semantics |
27 | 30 | import androidx.compose.ui.tooling.preview.Preview
|
28 | 31 | import androidx.compose.ui.viewinterop.AndroidView
|
29 | 32 | import com.arcgismaps.mapping.view.MapView
|
30 | 33 | import kotlinx.coroutines.launch
|
31 | 34 |
|
| 35 | +/** |
| 36 | + * A compose equivalent of the [MapView]. |
| 37 | + * |
| 38 | + * @param modifier Modifier to be applied to the Map |
| 39 | + * @param mapState the state of the Map |
| 40 | + * @param overlay the composable overlays to display on top of the Map. Example, a compass, floorfilter etc. |
| 41 | + * @since 200.3.0 |
| 42 | + */ |
32 | 43 | @Composable
|
33 |
| -public fun Map(modifier: Modifier = Modifier, mapState: MapState = MapState()) { |
| 44 | +public fun Map( |
| 45 | + modifier: Modifier = Modifier, |
| 46 | + mapState: MapState = MapState(), |
| 47 | + overlay: @Composable () -> Unit = {} |
| 48 | +) { |
34 | 49 |
|
35 | 50 | val lifecycleOwner = LocalLifecycleOwner.current
|
36 | 51 | val context = LocalContext.current
|
37 | 52 | val mapView = remember { MapView(context) }
|
38 | 53 |
|
39 |
| - AndroidView(modifier = modifier, factory = { mapView }) |
| 54 | + Box(modifier = Modifier.semantics { |
| 55 | + contentDescription = "MapContainer" |
| 56 | + }) { |
| 57 | + AndroidView(modifier = modifier |
| 58 | + .semantics { |
| 59 | + contentDescription = "MapView" |
| 60 | + }, factory = { mapView }) |
| 61 | + |
| 62 | + overlay() |
| 63 | + } |
40 | 64 |
|
41 | 65 | DisposableEffect(Unit) {
|
42 | 66 | lifecycleOwner.lifecycle.addObserver(mapView)
|
|
0 commit comments