Skip to content

feat: add onCameraFollowLocationChanged callback to NavigationView#549

Open
christian-apollo wants to merge 1 commit intogooglemaps:mainfrom
christian-apollo:feat/on-camera-follow-location-changed
Open

feat: add onCameraFollowLocationChanged callback to NavigationView#549
christian-apollo wants to merge 1 commit intogooglemaps:mainfrom
christian-apollo:feat/on-camera-follow-location-changed

Conversation

@christian-apollo
Copy link

@christian-apollo christian-apollo commented Mar 17, 2026

Summary

Adds a new onCameraFollowLocationChanged event prop to NavigationView that 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.setOnFollowMyLocationCallback to emit onCameraFollowLocationChanged events when the camera starts/stops following the user's location.

iOS — Tracks GMSNavigationCameraMode transitions via GMSMapViewDelegate methods (willMove:, idleAtCameraPosition:, mapViewDidTapRecenterButton:) and reports state changes. Also fires on programmatic transitions like showRouteOverview and setFollowingPerspective:.

TypeScript — Adds the onCameraFollowLocationChanged prop to NavigationViewProps and wires it through NativeNavViewComponent.

Usage

<NavigationView
  onCameraFollowLocationChanged={(isFollowing) => {
    console.log('Camera is following:', isFollowing);
  }}
/>

Test plan

  • Verify on Android: pan the map away → callback fires with false; tap the built-in recenter button → callback fires with true
  • Verify on iOS: same pan/recenter behavior
  • Verify showRouteOverview triggers false on iOS
  • Verify setFollowingPerspective triggers true on iOS
  • Verify no callback fires when the state hasn't actually changed (deduplication)

Made with Cursor

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
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