Skip to content

Map gestures (drag, pinch-to-zoom) broken when app runs in secondary pane on dual-pane/multi-window displays #2717

@mani-apps

Description

@mani-apps

Environment

  • Android OS version: Android Automotive OS (Android 13+)
  • Devices affected: Infotainment systems with dual-pane displays. Likely affects any Android Automotive or multi-window setup where the app runs in a secondary pane with a non-zero display offset.
  • Maps SDK Version: 11.16.2 (Mapbox Maps SDK for Android)

Observed behavior and steps to reproduce

  1. Run an app containing a MapboxMap (Compose) or MapView in a dual-pane / split-screen configuration where the app is positioned in the right/secondary pane
  2. Attempt to drag (pan) the map — the camera does not move
  3. Attempt to pinch-to-zoom — the gesture either doesn't respond or zooms to the wrong focal point
  4. Tap on the map — this works correctly
  5. Fast fling (drag and lift quickly) — may partially work, moving the camera via the fling animation

The issue does not occur when the app runs in the left/primary pane or in full-screen mode.

Diagnostic findings

We instrumented touch events on the MapView and found:

Left pane (working) Right pane (broken)
getX() / getY() Correct (view-relative) Correct (view-relative)
getRawX() / getRawY() Same as getX/Y Offset by pane position (~860–2880px in X)
getLocationOnScreen() (0, 0) (0, 0)incorrect, should reflect pane offset
getLocationInWindow() (0, 0) (0, 0)

The SDK's internal gesture detectors (e.g. MoveGestureDetector) appear to use getRawX()/getRawY() for focal point calculations. Since getLocationOnScreen() incorrectly reports (0, 0) on the right pane, the SDK cannot compensate for the display offset, resulting in a focal point that is off by the pane's X offset (e.g. ~2880px on a wide display).

Expected behavior

Drag, pinch-to-zoom, and all other map gestures should work correctly regardless of the app's position on the display — including when running in a secondary pane in a dual-pane or multi-window configuration.

Notes / preliminary analysis

The root cause appears to be in the gesture handling pipeline within the SDK. Specifically:

  • The gesture detectors use MotionEvent.getRawX()/getRawY() (display-absolute coordinates) for focal point and movement delta calculations
  • On dual-pane automotive displays, the MapView reports getLocationOnScreen() = (0, 0) even when it has a significant display offset, so the SDK cannot correct for the difference between raw and local coordinates
  • This is similar to the issue fixed in PR #1575 (MapSurface#surfaceChanged not updating dimensions for plugins) and related to issue #2131 (coordinate projection issues)

Our workaround: We intercept touch events via setOnTouchListener and create corrected MotionEvent copies (using MotionEvent.obtain() with PointerCoords from getPointerCoords()) where getRawX() == getX(), then dispatch the corrected event to MapView.onTouchEvent(). This resolves the issue for all gesture types.

A proper SDK fix would likely involve the gesture detectors using view-relative coordinates (getX()/getY()) instead of getRawX()/getRawY(), or correctly accounting for the view's screen position when computing focal points.

Additional links and references

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🪲Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions