rnmapbox / maps

A Mapbox react native module for creating custom maps
MIT License
2.13k stars 827 forks source link

[Bug]: Follow user location is lost when zooming the map in/out #3115

Open jaltin opened 9 months ago

jaltin commented 9 months ago

Mapbox Implementation

Mapbox

Mapbox Version

default

Platform

iOS, Android

@rnmapbox/maps version

10.0.0-beta.11

Standalone component to reproduce

// This example shows the bug
// https://github.com/rnmapbox/maps/blob/main/example/src/examples/UserLocation/UserLocationRenderMode.tsx

Observed behavior and steps to reproduce

When in follow user location and I zoom in/out, the follow user location mode is lost and the user needs to reactivate the follow user location.

This applies in the following zoom scenarios:

See this example video of the issue (play it with sound):

https://github.com/rnmapbox/maps/assets/2103778/ced041c7-a6f1-40f2-a352-c521bdbd6e3d

Expected behavior

In the pre-v10 RN mapbox library this was not happening, as the follow user location was kept when zooming.

This is also how both apple and google maps works, and I think this is how RN mapbox should also work. I also tested the Mapbox sample app available in the Android app store, and there it works like Apple and Google maps apps.

I have attached a video of our app that shows how it worked before the v10 update. Turn on sound as I explain the issue in the video too.

https://github.com/rnmapbox/maps/assets/2103778/3071e5b2-add0-4499-b314-fa57e6fc78ee

Notes / preliminary analysis

No response

Additional links and references

No response

mfazekas commented 8 months ago

I guess we want to expose https://docs.mapbox.com/android/maps/api/10.6.1/mapbox-maps-android/com.mapbox.maps.plugin.viewport.data/-viewport-options/transitions-to-idle-upon-user-interaction.html

https://docs.mapbox.com/ios/maps/api/10.6.1/Structs/ViewportOptions.html#/s:10MapboxMaps15ViewportOptionsV36transitionsToIdleUponUserInteractionSbvp

jaltin commented 8 months ago

@mfazekas yes that seems like it should fix the issue.

Is that a hard thing for you to implement?

jaltin commented 8 months ago

Hi @mfazekas, I see that you are working on viewport (https://github.com/rnmapbox/maps/issues/3155#issuecomment-1803737067).

Am I correct in thinking that it will also solve this issue?

mfazekas commented 8 months ago

@jaltin pls try current main, you can add a <Viewport transitionsToIdleUponUserInteraction={false} /> to the MapView and then it should alter the behaviour

andrei-tofan commented 8 months ago

@mfazekas thanks for the fix! Setting <Viewport transitionsToIdleUponUserInteraction={false} /> addresses the problem with the follow user location being lost on zoom, the problem is we want to exit from follow user mode on swipe as described in the video from 'Expected behavior' and with only using this setting this is not possible.

1) How we can capture the swipe user interaction to exist follow user mode? 2) How does gesturesSettings work with transitionsToIdleUponUserInteraction={false}? Asking because noticed that when is set to false sometimes the screen feels like is frozen when you try to zoom in. In the older version if you zoom while in follow user mode there is a delay of a few seconds and then the camera points back to the user's location.

andrei-tofan commented 8 months ago

@mfazekas do you have any ideas on how to address the scenario above?

jaltin commented 7 months ago

@mfazekas thanks for the fix! Setting <Viewport transitionsToIdleUponUserInteraction={false} /> addresses the problem with the follow user location being lost on zoom, the problem is we want to exit from follow user mode on swipe as described in the video from 'Expected behavior' and with only using this setting this is not possible.

  1. How we can capture the swipe user interaction to exist follow user mode?
  2. How does gesturesSettings work with transitionsToIdleUponUserInteraction={false}? Asking because noticed that when is set to false sometimes the screen feels like is frozen when you try to zoom in. In the older version if you zoom while in follow user mode there is a delay of a few seconds and then the camera points back to the user's location.

Hi @mfazekas,

Do you have any idea of how we can achieve what @andrei-tofan asked 3 weeks ago?

Thx!

mfazekas commented 7 months ago

@mfazekas sorry didn't have time to look into this.

andrei-tofan commented 6 months ago

Hi @mfazekas, do you think will have the time to look into this or at least give me some guidance on how to add support to this?

andrei-tofan commented 6 months ago

based on the mapbox documentation it looks like need to listen for gestures and update the camera accordingly to address this, right?

lgspacil commented 4 months ago

Any updates on this? I am running into a similar issue. transitionsToIdleUponUserInteraction={false} prevents all interaction with the map.

@andrei-tofan when you set transitionsToIdleUponUserInteraction={false} were you able to interact with the map?