Skip to content

fix(ios): keep a custom map view's gesture delegate - #4375

Merged
mfazekas merged 1 commit into
mainfrom
fix/ios-keep-factory-gesture-delegate
Oct 19, 2026
Merged

mfazekas merged 1 commit into
mainfrom
fix/ios-keep-factory-gesture-delegate

Conversation

@mfazekas

Copy link
Copy Markdown
Contributor

Description

RNMBXMapView.createMapView() sets mapView.gestures.delegate = self, which drops any delegate a map view from RNMBXMapViewFactory already had. With this change an existing delegate is added to the gesture delegates RNMBXMapView already forwards to (the weak set behind addGestureDelegate), so it keeps getting didBegin/didEnd/didEndAnimatingFor. Plain maps have no prior delegate, so nothing changes for them.

The use case is @rnmapbox/navigation, whose factory returns the MapView of a Navigation SDK NavigationMapView. That view is the gesture delegate and turns these callbacks into NavigationMapViewDelegate.navigationMapViewUserDidStartInteraction/DidEndInteraction. With this fix navigation can drop its workaround (an addTarget on every gesture recognizer) and set its camera state to idle from navigationMapViewUserDidStartInteraction instead.

Tested on an iOS 26.5 simulator:

  1. Navigation example with this branch as a portal:, simulated guidance in following mode. Before the fix the NavigationMapViewDelegate interaction callbacks never fire. With the fix and the workaround replaced by the delegate, pan, pinch, rotate and double-tap zoom each switch the camera state to idle, the same as with the workaround. Without the fix the delegate version stays in following.
  2. Maps example: Map Handlers press/long press and gesture callbacks work as before (there are no forwarded delegates on a plain map), and in SetUserTrackingModes a pan still switches Follow to None.

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

A map view returned by RNMBXMapViewFactory may already have a
gestures.delegate, e.g. a Navigation SDK NavigationMapView. Forward
gesture callbacks to it instead of dropping it.
@mfazekas
mfazekas merged commit a502b98 into main Oct 19, 2026
9 checks passed
@mfazekas
mfazekas deleted the fix/ios-keep-factory-gesture-delegate branch October 19, 2026 19:24
mfazekas added a commit to rnmapbox/navigation that referenced this pull request Oct 20, 2026
Use the tightened navigation SPI from rnmapbox/maps#4374: the factories
get an RNMBXMapView parent, so the casts and @preconcurrency go away, and
the Android camera-will-move listener is unregistered through the returned
Cancelable when the map detaches.

rnmapbox/maps#4375 keeps the factory map's gesture delegate on iOS, so the
gesture-recognizer workaround is replaced by
NavigationMapViewDelegate.navigationMapViewUserDidStartInteraction.
mfazekas added a commit to rnmapbox/navigation that referenced this pull request Oct 20, 2026
Use the tightened navigation SPI from rnmapbox/maps#4374: the factories
get an RNMBXMapView parent, so the casts and @preconcurrency go away, and
the Android camera-will-move listener is unregistered through the returned
Cancelable when the map detaches.

rnmapbox/maps#4375 keeps the factory map's gesture delegate on iOS, so the
gesture-recognizer workaround is replaced by
NavigationMapViewDelegate.navigationMapViewUserDidStartInteraction.
mfazekas added a commit to rnmapbox/navigation that referenced this pull request Oct 20, 2026
Use the tightened navigation SPI from rnmapbox/maps#4374: the factories
get an RNMBXMapView parent, so the casts and @preconcurrency go away, and
the Android camera-will-move listener is unregistered through the returned
Cancelable when the map detaches.

rnmapbox/maps#4375 keeps the factory map's gesture delegate on iOS, so the
gesture-recognizer workaround is replaced by
NavigationMapViewDelegate.navigationMapViewUserDidStartInteraction.

This branch was previously deployed

1 inactive deployment
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.

1 participant