Skip to content

Commit 32e5a4a

Browse files
authored
add support for onNavigationChanged (#199)
* add support for onNavigationChanged * add doc
1 parent 1886835 commit 32e5a4a

File tree

1 file changed

+10
-0
lines changed
  • toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose

1 file changed

+10
-0
lines changed

toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt

+10
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import kotlinx.coroutines.launch
7575
* @param wrapAroundMode the [WrapAroundMode] to specify whether continuous panning across the international date line is enabled
7676
* @param attributionState specifies the attribution bar's visibility, text changed and layout changed events
7777
* @param onViewpointChanged lambda invoked when the viewpoint of the composable MapView has changed
78+
* @param onNavigationChanged lambda invoked when the navigation status of the composable MapView has changed
7879
* @param onMapRotationChanged lambda invoked when the rotation of this composable MapView has changed
7980
* @param onMapScaleChanged lambda invoked when the scale of this composable MapView has changed
8081
* @param onSpatialReferenceChanged lambda invoked when the spatial reference of the composable MapView has changed
@@ -108,6 +109,7 @@ public fun MapView(
108109
wrapAroundMode: WrapAroundMode = WrapAroundMode.EnabledWhenSupported,
109110
attributionState: AttributionState = AttributionState(),
110111
onViewpointChanged: (() -> Unit)? = null,
112+
onNavigationChanged: ((isNavigating: Boolean) -> Unit)? = null,
111113
onMapRotationChanged: ((Double) -> Unit)? = null,
112114
onMapScaleChanged: ((Double) -> Unit)? = null,
113115
onSpatialReferenceChanged: ((spatialReference: SpatialReference?) -> Unit)? = null,
@@ -174,6 +176,7 @@ public fun MapView(
174176
MapViewEventHandler(
175177
mapView,
176178
onViewpointChanged,
179+
onNavigationChanged,
177180
onMapRotationChanged,
178181
onMapScaleChanged,
179182
onSpatialReferenceChanged,
@@ -223,6 +226,7 @@ private fun AttributionStateHandler(mapView: MapView, attributionState: Attribut
223226
private fun MapViewEventHandler(
224227
mapView: MapView,
225228
onViewpointChanged: (() -> Unit)?,
229+
onNavigationChanged: ((isNavigating: Boolean) -> Unit)?,
226230
onMapRotationChanged: ((Double) -> Unit)?,
227231
onMapScaleChanged: ((Double) -> Unit)?,
228232
onSpatialReferenceChanged: ((spatialReference: SpatialReference?) -> Unit)?,
@@ -239,6 +243,7 @@ private fun MapViewEventHandler(
239243
onDrawStatusChanged: ((DrawStatus) -> Unit)?
240244
) {
241245
val currentViewPointChanged by rememberUpdatedState(onViewpointChanged)
246+
val currentOnNavigationChanged by rememberUpdatedState(onNavigationChanged)
242247
val currentOnMapRotationChanged by rememberUpdatedState(onMapRotationChanged)
243248
val currentOnMapScaleChanged by rememberUpdatedState(onMapScaleChanged)
244249
val currentOnSpatialReferenceChanged by rememberUpdatedState(onSpatialReferenceChanged)
@@ -275,6 +280,11 @@ private fun MapViewEventHandler(
275280
currentOnSpatialReferenceChanged?.invoke(spatialReference)
276281
}
277282
}
283+
launch {
284+
mapView.navigationChanged.collect {
285+
currentOnNavigationChanged?.invoke(it)
286+
}
287+
}
278288
launch(Dispatchers.Main.immediate) {
279289
mapView.isInteracting.collect { isInteracting ->
280290
currentOnInteractingChanged?.invoke(isInteracting)

0 commit comments

Comments
 (0)