Skip to content

feat: add focalPoint - #4163

Draft
ted-mundy wants to merge 4 commits into
rnmapbox:mainfrom
ted-mundy:feature/focal-point
Draft

ted-mundy wants to merge 4 commits into
rnmapbox:mainfrom
ted-mundy:feature/focal-point

Conversation

@ted-mundy

@ted-mundy ted-mundy commented Feb 27, 2026 •

Copy link
Copy Markdown

Description

Added focalPoint into the React Native version of the package. Functionality already exists in both Android and iOS, but no bridge was ever built. This builds that bridge 🙂

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder
  • I have tested the new feature on /example app.
    • In V11 mode/ios
    • In New Architecture mode/ios
    • In V11 mode/android
    • In New Architecture mode/android
  • I added/updated a sample - if a new feature was implemented (/example)

Screenshot OR Video

See the Map > Gesture Focal Point example and the verification notes in the comments.

@ted-mundy
ted-mundy had a problem deploying to CI with Mapbox Tokens February 27, 2026 16:39 — with GitHub Actions Failure
@ted-mundy
ted-mundy had a problem deploying to CI with Mapbox Tokens February 27, 2026 16:39 — with GitHub Actions Failure
@ted-mundy
ted-mundy had a problem deploying to CI with Mapbox Tokens February 27, 2026 16:39 — with GitHub Actions Failure
…val, add example

Android converts the dp focal point to pixels for GesturesSettings.focalPoint.
Both platforms clear the focal point when it's removed from gestureSettings.
The doc generator now expands nested object types instead of printing
'signature'.
@mfazekas

Copy link
Copy Markdown
Contributor

Thanks @ted-mundy, this is a nice addition! I pushed a commit on top of yours (your commits are unchanged; I merged main in first) to finish it off:

  1. Android: focalPoint is now passed to GesturesSettings.focalPoint, converted from dp to pixels.
  2. Removing focalPoint from gestureSettings now resets it, on both iOS and Android.
  3. Docs: the generator now expands nested object types, so focalPoint shows as {x: number, y: number} instead of signature. Camera's padding was hitting the same issue and is fixed too. The description now says the point is in points/dp, relative to the map view's top-left.
  4. A new Map > Gesture Focal Point example. It draws a marker at the focal point, lets you toggle the focal point, and shows the coordinate under the marker. That coordinate should stay put while you zoom or rotate.

Both SDKs use the focal point for pinch, rotate, double-tap zoom-in and two-finger-tap zoom-out.

Verification: the gestures were run away from the marker, then I checked whether the coordinate under the marker moved.

  • iOS simulator: pinch, rotate and double-tap all kept the coordinate fixed with the focal point on. With it off, all three moved it, and turning it back on restored the pivot.
  • Android emulator (density 2.625): rotate, double-tap and two-finger tap kept the coordinate fixed with the focal point on, which also confirms the dp→px conversion. With it off, double-tap and two-finger tap moved it. Pinch with the focal point on couldn't be driven reliably by injected multi-touch on the emulator (pinch on other examples failed the same way), so that one still needs a check on a real device.

@ted-mundy

Copy link
Copy Markdown
Author

Am I ok to undraft this @mfazekas ?

This branch had an error being deployed

1 failed (outdated) and 1 active deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants