@@ -20,7 +20,6 @@ package com.arcgismaps.toolkit.geocompose
20
20
import androidx.compose.foundation.layout.Box
21
21
import androidx.compose.runtime.Composable
22
22
import androidx.compose.runtime.DisposableEffect
23
- import androidx.compose.runtime.LaunchedEffect
24
23
import androidx.compose.runtime.remember
25
24
import androidx.compose.ui.Modifier
26
25
import androidx.compose.ui.platform.LocalContext
@@ -29,27 +28,28 @@ import androidx.compose.ui.semantics.contentDescription
29
28
import androidx.compose.ui.semantics.semantics
30
29
import androidx.compose.ui.tooling.preview.Preview
31
30
import androidx.compose.ui.viewinterop.AndroidView
31
+ import com.arcgismaps.mapping.ArcGISMap
32
32
import com.arcgismaps.mapping.view.MapView
33
- import kotlinx.coroutines.launch
34
33
35
34
/* *
36
35
* A compose equivalent of the [MapView].
37
36
*
38
37
* @param modifier Modifier to be applied to the Map
39
- * @param mapState the state of the Map
38
+ * @param arcGISMap the [ArcGISMap] to be rendered by this composable
40
39
* @param overlay the composable overlays to display on top of the Map. Example, a compass, floorfilter etc.
41
40
* @since 200.3.0
42
41
*/
43
42
@Composable
44
43
public fun Map (
45
44
modifier : Modifier = Modifier ,
46
- mapState : MapState = MapState () ,
45
+ arcGISMap : ArcGISMap ? = null ,
47
46
overlay : @Composable () -> Unit = {}
48
47
) {
49
-
50
48
val lifecycleOwner = LocalLifecycleOwner .current
51
49
val context = LocalContext .current
52
- val mapView = remember { MapView (context) }
50
+ val mapView = remember { MapView (context) }.apply {
51
+ map = arcGISMap
52
+ }
53
53
54
54
Box (modifier = Modifier .semantics {
55
55
contentDescription = " MapContainer"
@@ -69,14 +69,6 @@ public fun Map(
69
69
mapView.onDestroy(lifecycleOwner)
70
70
}
71
71
}
72
-
73
- LaunchedEffect (mapState) {
74
- launch {
75
- mapState.arcGISMap.collect {
76
- mapView.map = it
77
- }
78
- }
79
- }
80
72
}
81
73
82
74
@Preview
0 commit comments