googlemaps / react-native-navigation-sdk

Apache License 2.0
19 stars 3 forks source link

Programmatically recenter map #202

Closed nexttrack07 closed 1 month ago

nexttrack07 commented 2 months ago

After using either moveCamera or showRouteOverview, is it possible to programmatically recenter the map instead of expecting the user to click on the recenter button?

After either of those functions are called, the user is not centered and following the navigation path unless he clicks on Re-center

Thanks

illuminati1911 commented 2 months ago

Hey @nexttrack07. I incorrectly stated earlier that this is not possible. Sorry about that. You can recenter the camera programmatically by calling setFollowingPerspective function of the NavigationViewController. Which ever perspective you choose, the camera will recenter at the same time.

Let us know if this works for you!

nexttrack07 commented 2 months ago

Thanks. We are on 0.3.3-beta and the setFollowingPerspective function does not cause the camera to follow the user. Is this fixed in the new 1.0.0-beta release?

illuminati1911 commented 2 months ago

@nexttrack07 At least in my testing it seems to work. You can test it with the new version (btw. we changed the version number from 1.0.0-beta to 0.4.0-beta) however it's not yet available on the npm. Only here on github for now.

nexttrack07 commented 2 months ago

@illuminati1911 - Hey thanks for responding. However, I retested with the old version (0.3.3-beta) and the latest version (0.4.0) and it doesn't seem to work in either one.

Here are the steps to reproduce in the latest example app:

  1. Set destination with some lat lng
  2. Start simulation and guidance - This will cause the camera to follow the user simulation
  3. Click Show Route Overview - This will cause camera to zoom out and show the entire view but simulation will continue
  4. Select camera perspective using setFollowingPerspective (any of the three options) - This does not zoom in to the user and follow simulation
Screenshot 2024-07-30 at 11 01 30 PM Screenshot 2024-07-30 at 11 02 16 PM

This is a critical bug for and we are eagerly awaiting your response. Our app release is very soon and we'd like to see if this is something we can fix.

Just to re-iterate the request: You can see in the photos that the map is zoomed out and camera doesn't follow simulation. The user will need to manually click on the re-center button in order to achieve this. We want to be able to do this programmatically.

tfranzese-woolpert commented 1 month ago

For iOS the camera mode needs to be set back to following:

setFollowingPerspective(CameraPerspective.TOP_DOWN_HEADING_UP);
setCameraMode(CameraMode.FOLLOWING);

I believe that API is specific to the iOS Navigation SDK, see https://developers.google.com/maps/documentation/navigation/ios-sdk/camera#automatically_recenter_the_map

setCameraMode is not currently exposed by the React Native Navigation SDK.

akilakumarasamy commented 1 month ago

The map is not following the user's location during turn-by-turn navigation is a critical issue with the navigation functionality. This behavior is essential for the core functionality of the navigation project. Without this, the navigation experience is significantly compromised, making the application effectively unusable for its intended purpose. This issue is a major blocker for our project's launch, and we are unable to proceed without a resolution. We would greatly appreciate for a fix or a viable workaround to address this problem.