Repository navigation
feat: let native code know when Camera is about to move the map - #4371
Merged
Merged
Conversation
Add a per-map hook on RNMBXMapView, called right before <Camera> moves the map from its stop props (and setCamera, fitBounds, flyTo, ...), moveBy, scaleBy or followUserLocation. Native code driving the same map, such as a navigation camera adopting it through RNMBXMapViewFactory, can then yield. iOS: RNMBXCameraDelegate with RNMBXMapView.addCameraDelegate / removeCameraDelegate (weak, like addGestureDelegate). Android: OnCameraWillMoveMapListener with RNMBXMapView.addOnCameraWillMoveMapListener / removeOnCameraWillMoveMapListener.
mfazekas
force-pushed
the
feat/camera-will-move-map-notification
branch
from
October 19, 2026 06:03
adadd71 to
1fb77b5
Compare
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added a native hook on
RNMBXMapViewthat is called right before<Camera>moves the map. Native code that shares the map, e.g. a navigation camera adopting it throughRNMBXMapViewFactory, needs to yield when<Camera>takes over, otherwise it snaps the map back.It is called for the
stopprops (includingsetCamera/fitBounds/flyTo/moveTo/zoomTovia ref),moveBy,scaleByandfollowUserLocation, but not fordefaultSettingsor user gestures. It follows the existing per-mapaddGestureDelegatepattern rather than adding aNotificationCentername, so both platforms share the same concept:RNMBXCameraDelegate.cameraWillMoveMap(_:), registered withRNMBXMapView.addCameraDelegate(_:)/removeCameraDelegate(_:)(weak).OnCameraWillMoveMapListener.onCameraWillMoveMap(mapView), registered withRNMBXMapView.addOnCameraWillMoveMapListener/removeOnCameraWillMoveMapListener.On Android, animated moves were already visible through
CameraAnimationsLifecycleListener, but instant moves (animationDuration: 0,setCamera) and viewport transitions are not.Checklist
CONTRIBUTING.mdyarn generatein the root folder (native-only API, nothing generated)/exampleapp./example)Screenshot OR Video
Tested with a temporary example screen (below) plus a temporary native delegate/listener that logs every call, kept out of this PR. On both platforms each of prop instant, prop animated,
setCameraandmoveByproduced exactly one call, with theRNMBXMapViewhosting the map; pans/swipes produced none. On Android, aCameraAnimationsLifecycleListenerlogged alongside saw nothing for the instant prop move and the instantsetCamera.Component to reproduce the issue you're fixing