Skip to content

add support for onNavigationChanged #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import kotlinx.coroutines.launch
* @param wrapAroundMode the [WrapAroundMode] to specify whether continuous panning across the international date line is enabled
* @param attributionState specifies the attribution bar's visibility, text changed and layout changed events
* @param onViewpointChanged lambda invoked when the viewpoint of the composable MapView has changed
* @param onNavigationChanged lambda invoked when the navigation status of the composable MapView has changed
* @param onMapRotationChanged lambda invoked when the rotation of this composable MapView has changed
* @param onMapScaleChanged lambda invoked when the scale of this composable MapView has changed
* @param onSpatialReferenceChanged lambda invoked when the spatial reference of the composable MapView has changed
Expand Down Expand Up @@ -108,6 +109,7 @@ public fun MapView(
wrapAroundMode: WrapAroundMode = WrapAroundMode.EnabledWhenSupported,
attributionState: AttributionState = AttributionState(),
onViewpointChanged: (() -> Unit)? = null,
onNavigationChanged: ((isNavigating: Boolean) -> Unit)? = null,

This comment was marked as resolved.

This comment was marked as resolved.

onMapRotationChanged: ((Double) -> Unit)? = null,
onMapScaleChanged: ((Double) -> Unit)? = null,
onSpatialReferenceChanged: ((spatialReference: SpatialReference?) -> Unit)? = null,
Expand Down Expand Up @@ -174,6 +176,7 @@ public fun MapView(
MapViewEventHandler(
mapView,
onViewpointChanged,
onNavigationChanged,
onMapRotationChanged,
onMapScaleChanged,
onSpatialReferenceChanged,
Expand Down Expand Up @@ -223,6 +226,7 @@ private fun AttributionStateHandler(mapView: MapView, attributionState: Attribut
private fun MapViewEventHandler(
mapView: MapView,
onViewpointChanged: (() -> Unit)?,
onNavigationChanged: ((isNavigating: Boolean) -> Unit)?,
onMapRotationChanged: ((Double) -> Unit)?,
onMapScaleChanged: ((Double) -> Unit)?,
onSpatialReferenceChanged: ((spatialReference: SpatialReference?) -> Unit)?,
Expand All @@ -239,6 +243,7 @@ private fun MapViewEventHandler(
onDrawStatusChanged: ((DrawStatus) -> Unit)?
) {
val currentViewPointChanged by rememberUpdatedState(onViewpointChanged)
val currentOnNavigationChanged by rememberUpdatedState(onNavigationChanged)
val currentOnMapRotationChanged by rememberUpdatedState(onMapRotationChanged)
val currentOnMapScaleChanged by rememberUpdatedState(onMapScaleChanged)
val currentOnSpatialReferenceChanged by rememberUpdatedState(onSpatialReferenceChanged)
Expand Down Expand Up @@ -275,6 +280,11 @@ private fun MapViewEventHandler(
currentOnSpatialReferenceChanged?.invoke(spatialReference)
}
}
launch {
mapView.navigationChanged.collect {
currentOnNavigationChanged?.invoke(it)
}
}
launch(Dispatchers.Main.immediate) {
mapView.isInteracting.collect { isInteracting ->
currentOnInteractingChanged?.invoke(isInteracting)
Expand Down