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 1 commit
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 @@ -99,6 +99,7 @@ public fun MapView(
backgroundGrid: BackgroundGrid = BackgroundGrid(),
onViewpointChanged: (() -> Unit)? = null,
onInteractingChanged: ((isInteracting: Boolean) -> Unit)? = null,
onNavigationChanged: ((isNavigating: Boolean) -> Unit)? = null,

This comment was marked as resolved.

This comment was marked as resolved.

onRotate: ((RotationChangeEvent) -> Unit)? = null,
onScale: ((ScaleChangeEvent) -> Unit)? = null,
onUp: ((UpEvent) -> Unit)? = null,
Expand Down Expand Up @@ -146,6 +147,7 @@ public fun MapView(
mapView,
onViewpointChanged,
onInteractingChanged,
onNavigationChanged,
onRotate,
onScale,
onUp,
Expand All @@ -169,6 +171,7 @@ private fun MapViewEventHandler(
mapView: MapView,
onViewpointChanged: (() -> Unit)?,
onInteractingChanged: ((isInteracting: Boolean) -> Unit)?,
onNavigationChanged: ((isNavigating: Boolean) -> Unit)?,
onRotate: ((RotationChangeEvent) -> Unit)?,
onScale: ((ScaleChangeEvent) -> Unit)?,
onUp: ((UpEvent) -> Unit)?,
Expand All @@ -182,6 +185,7 @@ private fun MapViewEventHandler(
) {
val currentViewPointChanged by rememberUpdatedState(onViewpointChanged)
val currentOnInteractingChanged by rememberUpdatedState(onInteractingChanged)
val currentOnNavigationChanged by rememberUpdatedState(onNavigationChanged)
val currentOnRotate by rememberUpdatedState(onRotate)
val currentOnScale by rememberUpdatedState(onScale)
val currentOnUp by rememberUpdatedState(onUp)
Expand All @@ -208,6 +212,11 @@ private fun MapViewEventHandler(
}
}
}
launch(Dispatchers.Main.immediate) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NavigationChanged is a Core event, no need for Dispatchers.Main.immediate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

mapView.navigationChanged.collect {
currentOnNavigationChanged?.invoke(it)
}
}
launch(Dispatchers.Main.immediate) {
mapView.onRotate.collect { rotationChangeEvent ->
currentOnRotate?.let {
Expand Down