From c8e1c8a10c8f4fd3a9510bd38edb5d474481416f Mon Sep 17 00:00:00 2001 From: Otto Ranta-Ojala Date: Sun, 1 Feb 2026 10:39:34 +0200 Subject: [PATCH] Fixed parent view from stealing map pan gesture --- .../rngooglemapsplus/GoogleMapsViewImpl.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt b/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt index 9bd6e0f..5aacaa9 100644 --- a/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +++ b/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt @@ -10,7 +10,9 @@ import android.content.res.Configuration import android.graphics.Bitmap import android.location.Location import android.util.Size +import android.view.MotionEvent import android.view.View +import android.view.ViewGroup import android.widget.FrameLayout import androidx.lifecycle.Lifecycle import androidx.lifecycle.findViewTreeLifecycleOwner @@ -181,6 +183,30 @@ class GoogleMapsViewImpl( } } + private fun disallowParentTouchEventIntercept(disallowIntercept: Boolean): Boolean { + val parent = this.parent as? ViewGroup + if (parent != null) { + parent.requestDisallowInterceptTouchEvent(disallowIntercept) + return true + } + return false + } + + override fun dispatchTouchEvent(ev: MotionEvent): Boolean { + when (ev.actionMasked) { + MotionEvent.ACTION_DOWN -> { + disallowParentTouchEventIntercept( + googleMap?.uiSettings?.isScrollGesturesEnabled ?: false + ) + } + MotionEvent.ACTION_UP -> { + disallowParentTouchEventIntercept(false) + } + } + super.dispatchTouchEvent(ev) + return true + } + override fun onCameraMoveStarted(reason: Int) = onUi { if (!mapViewLoaded) return@onUi