From 9cc96964885a41953c8c9dd6cfed7a7ee365a16f Mon Sep 17 00:00:00 2001 From: Shubham Sharma Date: Tue, 7 Nov 2023 11:54:25 -0800 Subject: [PATCH 1/4] impl map scale & rotation --- .../arcgismaps/toolkit/geocompose/MapView.kt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt b/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt index 052619184..744013093 100644 --- a/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt +++ b/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt @@ -72,7 +72,9 @@ import kotlinx.coroutines.launch * @param onViewpointChanged lambda invoked when the viewpoint of the composable MapView has changed * @param onInteractingChanged lambda invoked when the user starts and ends interacting with the composable MapView * @param onRotate lambda invoked when a user performs a rotation gesture on the composable MapView + * @param onMapRotationChanged lambda invoked with the composable MapView's current rotation * @param onScale lambda invoked when a user performs a pinch gesture on the composable MapView + * @param onMapScaleChanged lambda invoked with the composable MapView's current scale * @param onUp lambda invoked when the user removes all their pointers from the composable MapView * @param onDown lambda invoked when the user first presses on the composable MapView * @param onSingleTapConfirmed lambda invoked when the user taps once on the composable MapView @@ -100,7 +102,9 @@ public fun MapView( onViewpointChanged: (() -> Unit)? = null, onInteractingChanged: ((isInteracting: Boolean) -> Unit)? = null, onRotate: ((RotationChangeEvent) -> Unit)? = null, + onMapRotationChanged: ((Double) -> Unit)? = null, onScale: ((ScaleChangeEvent) -> Unit)? = null, + onMapScaleChanged: ((Double) -> Unit)? = null, onUp: ((UpEvent) -> Unit)? = null, onDown: ((DownEvent) -> Unit)? = null, onSingleTapConfirmed: ((SingleTapConfirmedEvent) -> Unit)? = null, @@ -147,7 +151,9 @@ public fun MapView( onViewpointChanged, onInteractingChanged, onRotate, + onMapRotationChanged, onScale, + onMapScaleChanged, onUp, onDown, onSingleTapConfirmed, @@ -170,7 +176,9 @@ private fun MapViewEventHandler( onViewpointChanged: (() -> Unit)?, onInteractingChanged: ((isInteracting: Boolean) -> Unit)?, onRotate: ((RotationChangeEvent) -> Unit)?, + onMapRotationChanged: ((Double) -> Unit)?, onScale: ((ScaleChangeEvent) -> Unit)?, + onMapScaleChanged: ((Double) -> Unit)?, onUp: ((UpEvent) -> Unit)?, onDown: ((DownEvent) -> Unit)?, onSingleTapConfirmed: ((SingleTapConfirmedEvent) -> Unit)?, @@ -183,7 +191,9 @@ private fun MapViewEventHandler( val currentViewPointChanged by rememberUpdatedState(onViewpointChanged) val currentOnInteractingChanged by rememberUpdatedState(onInteractingChanged) val currentOnRotate by rememberUpdatedState(onRotate) + val currentOnMapRotationChanged by rememberUpdatedState(onMapRotationChanged) val currentOnScale by rememberUpdatedState(onScale) + val currentOnMapScaleChanged by rememberUpdatedState(onMapScaleChanged) val currentOnUp by rememberUpdatedState(onUp) val currentOnDown by rememberUpdatedState(onDown) val currentSingleTapConfirmed by rememberUpdatedState(onSingleTapConfirmed) @@ -201,6 +211,16 @@ private fun MapViewEventHandler( } } } + launch { + mapView.mapRotation.collect { mapRotation -> + currentOnMapRotationChanged?.invoke(mapRotation) + } + } + launch { + mapView.mapScale.collect { mapScale -> + currentOnMapScaleChanged?.invoke(mapScale) + } + } launch(Dispatchers.Main.immediate) { mapView.isInteracting.collect { isInteracting -> currentOnInteractingChanged?.let { From b79207e6aafb0f96b69459eaaddad6e8ca22cbde Mon Sep 17 00:00:00 2001 From: Shubham Sharma Date: Thu, 9 Nov 2023 10:52:24 -0800 Subject: [PATCH 2/4] moved onMapRotationChanged & onMapScaleChanged --- .../arcgismaps/toolkit/geocompose/MapView.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt b/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt index 4a25fa1b9..49e4775c5 100644 --- a/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt +++ b/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt @@ -69,12 +69,12 @@ import kotlinx.coroutines.launch * @param grid represents the display of a coordinate system [Grid] on the composable MapView * @param backgroundGrid the default color and context grid behind the map surface * @param wrapAroundMode the [WrapAroundMode] to specify whether continuous panning across the international date line is enabled - * @param onViewpointChanged lambda invoked when the viewpoint of the composable MapView has changed - * @param onInteractingChanged lambda invoked when the user starts and ends interacting with the composable MapView - * @param onRotate lambda invoked when a user performs a rotation gesture on the composable MapView + * @param onViewpointChanged lambda invoked when the viewpoint of the composable MapView has changedMapView * @param onMapRotationChanged lambda invoked with the composable MapView's current rotation - * @param onScale lambda invoked when a user performs a pinch gesture on the composable MapView * @param onMapScaleChanged lambda invoked with the composable MapView's current scale + * @param onInteractingChanged lambda invoked when the user starts and ends interacting with the composable MapView + * @param onRotate lambda invoked when a user performs a rotation gesture on the composable + * @param onScale lambda invoked when a user performs a pinch gesture on the composable MapView * @param onUp lambda invoked when the user removes all their pointers from the composable MapView * @param onDown lambda invoked when the user first presses on the composable MapView * @param onSingleTapConfirmed lambda invoked when the user taps once on the composable MapView @@ -100,11 +100,11 @@ public fun MapView( grid: Grid? = null, backgroundGrid: BackgroundGrid = BackgroundGrid(), onViewpointChanged: (() -> Unit)? = null, + onMapRotationChanged: ((Double) -> Unit)? = null, + onMapScaleChanged: ((Double) -> Unit)? = null, onInteractingChanged: ((isInteracting: Boolean) -> Unit)? = null, onRotate: ((RotationChangeEvent) -> Unit)? = null, - onMapRotationChanged: ((Double) -> Unit)? = null, onScale: ((ScaleChangeEvent) -> Unit)? = null, - onMapScaleChanged: ((Double) -> Unit)? = null, onUp: ((UpEvent) -> Unit)? = null, onDown: ((DownEvent) -> Unit)? = null, onSingleTapConfirmed: ((SingleTapConfirmedEvent) -> Unit)? = null, @@ -149,11 +149,11 @@ public fun MapView( MapViewEventHandler( mapView, onViewpointChanged, + onMapRotationChanged, + onMapScaleChanged, onInteractingChanged, onRotate, - onMapRotationChanged, onScale, - onMapScaleChanged, onUp, onDown, onSingleTapConfirmed, @@ -174,11 +174,11 @@ public fun MapView( private fun MapViewEventHandler( mapView: MapView, onViewpointChanged: (() -> Unit)?, + onMapRotationChanged: ((Double) -> Unit)?, + onMapScaleChanged: ((Double) -> Unit)?, onInteractingChanged: ((isInteracting: Boolean) -> Unit)?, onRotate: ((RotationChangeEvent) -> Unit)?, - onMapRotationChanged: ((Double) -> Unit)?, onScale: ((ScaleChangeEvent) -> Unit)?, - onMapScaleChanged: ((Double) -> Unit)?, onUp: ((UpEvent) -> Unit)?, onDown: ((DownEvent) -> Unit)?, onSingleTapConfirmed: ((SingleTapConfirmedEvent) -> Unit)?, @@ -189,11 +189,11 @@ private fun MapViewEventHandler( onDrawStatusChanged: ((DrawStatus) -> Unit)? ) { val currentViewPointChanged by rememberUpdatedState(onViewpointChanged) + val currentOnMapRotationChanged by rememberUpdatedState(onMapRotationChanged) + val currentOnMapScaleChanged by rememberUpdatedState(onMapScaleChanged) val currentOnInteractingChanged by rememberUpdatedState(onInteractingChanged) val currentOnRotate by rememberUpdatedState(onRotate) - val currentOnMapRotationChanged by rememberUpdatedState(onMapRotationChanged) val currentOnScale by rememberUpdatedState(onScale) - val currentOnMapScaleChanged by rememberUpdatedState(onMapScaleChanged) val currentOnUp by rememberUpdatedState(onUp) val currentOnDown by rememberUpdatedState(onDown) val currentSingleTapConfirmed by rememberUpdatedState(onSingleTapConfirmed) From e9d58a178b038d094a155b6c6b190329f1ef3784 Mon Sep 17 00:00:00 2001 From: Shubham Sharma Date: Thu, 9 Nov 2023 10:53:42 -0800 Subject: [PATCH 3/4] fix comments --- .../main/java/com/arcgismaps/toolkit/geocompose/MapView.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt b/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt index 49e4775c5..7ecadf423 100644 --- a/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt +++ b/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt @@ -69,11 +69,11 @@ import kotlinx.coroutines.launch * @param grid represents the display of a coordinate system [Grid] on the composable MapView * @param backgroundGrid the default color and context grid behind the map surface * @param wrapAroundMode the [WrapAroundMode] to specify whether continuous panning across the international date line is enabled - * @param onViewpointChanged lambda invoked when the viewpoint of the composable MapView has changedMapView + * @param onViewpointChanged lambda invoked when the viewpoint of the composable MapView has changed * @param onMapRotationChanged lambda invoked with the composable MapView's current rotation * @param onMapScaleChanged lambda invoked with the composable MapView's current scale * @param onInteractingChanged lambda invoked when the user starts and ends interacting with the composable MapView - * @param onRotate lambda invoked when a user performs a rotation gesture on the composable + * @param onRotate lambda invoked when a user performs a rotation gesture on the composable MapView * @param onScale lambda invoked when a user performs a pinch gesture on the composable MapView * @param onUp lambda invoked when the user removes all their pointers from the composable MapView * @param onDown lambda invoked when the user first presses on the composable MapView From 2b8a75ee8d5a44966a389845dd7afa255a5f80ec Mon Sep 17 00:00:00 2001 From: Shubham Sharma Date: Mon, 13 Nov 2023 07:57:33 -0800 Subject: [PATCH 4/4] add PR feedback --- .../main/java/com/arcgismaps/toolkit/geocompose/MapView.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt b/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt index 7ecadf423..ec7a92580 100644 --- a/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt +++ b/toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapView.kt @@ -70,8 +70,8 @@ import kotlinx.coroutines.launch * @param backgroundGrid the default color and context grid behind the map surface * @param wrapAroundMode the [WrapAroundMode] to specify whether continuous panning across the international date line is enabled * @param onViewpointChanged lambda invoked when the viewpoint of the composable MapView has changed - * @param onMapRotationChanged lambda invoked with the composable MapView's current rotation - * @param onMapScaleChanged lambda invoked with the composable MapView's current scale + * @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 onInteractingChanged lambda invoked when the user starts and ends interacting with the composable MapView * @param onRotate lambda invoked when a user performs a rotation gesture on the composable MapView * @param onScale lambda invoked when a user performs a pinch gesture on the composable MapView