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

@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
@jokerttu jokerttu added the priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. label Apr 10, 2026
Copy link
Copy Markdown
Contributor

@jokerttu jokerttu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please add usage demonstration in example/src/screens/NavigationScreen.tsx (similar to how onRecenterButtonClick is used)
  • Add e2e test in example/e2e/event_listener.test.js following existing patterns
    • Make it so that this verifies that Android and iOS fire the callback in the same scenarios? As the implementations differ (native callback vs manual tracking).
  • _lastReportedIsFollowing defaults to false, so if camera starts in following mode, the initial true state won't be reported. Consider initializing it based on actual camera mode at mapview init?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants