feat: add onCameraFollowLocationChanged callback to NavigationView#549
Open
christian-apollo wants to merge 1 commit intogooglemaps:mainfrom
Open
feat: add onCameraFollowLocationChanged callback to NavigationView#549christian-apollo wants to merge 1 commit intogooglemaps:mainfrom
christian-apollo wants to merge 1 commit intogooglemaps:mainfrom
Conversation
Add a new `onCameraFollowLocationChanged` event prop to `NavigationView` that fires whenever the camera enters or exits follow-my-location mode. **Android:** Uses `GoogleMap.setOnFollowMyLocationCallback` to emit events when the camera starts/stops following the user's location. **iOS:** Tracks `GMSNavigationCameraMode` changes via GMSMapView delegate methods (`willMove:`, `idleAtCameraPosition:`, `mapViewDidTapRecenterButton:`) and reports state transitions. Also fires on programmatic changes like `showRouteOverview` and `setFollowingPerspective`. This enables apps to show/hide a custom recenter button or adjust UI based on whether the map is actively tracking the user's position. Made-with: Cursor
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.
Summary
Adds a new
onCameraFollowLocationChangedevent prop toNavigationViewthat fires whenever the camera enters or exits follow-my-location mode. This enables apps to reactively show/hide a custom recenter button or adjust their UI based on whether the map is actively tracking the user's position.Motivation
There is currently no way to know when the user pans the map away from the follow-my-location camera mode, or when it re-enters following mode (e.g. after tapping the built-in recenter button). Apps that overlay custom UI on top of the navigation view (such as a bottom sheet or custom recenter button) need this signal to stay in sync.
Changes
Android — Uses
GoogleMap.setOnFollowMyLocationCallbackto emitonCameraFollowLocationChangedevents when the camera starts/stops following the user's location.iOS — Tracks
GMSNavigationCameraModetransitions viaGMSMapViewDelegatemethods (willMove:,idleAtCameraPosition:,mapViewDidTapRecenterButton:) and reports state changes. Also fires on programmatic transitions likeshowRouteOverviewandsetFollowingPerspective:.TypeScript — Adds the
onCameraFollowLocationChangedprop toNavigationViewPropsand wires it throughNativeNavViewComponent.Usage
Test plan
false; tap the built-in recenter button → callback fires withtrueshowRouteOverviewtriggersfalseon iOSsetFollowingPerspectivetriggerstrueon iOSMade with Cursor