-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Follow Me Button": Map stutters slowly when using onPanDrag + scrollEnabled={false} on iOS #1038
Comments
I ran into the same problem. I guess the problem is that the coordinates are not that accurate and re-render too frequently will make it unusable. So I tried something similar to a PID controller. When I get a new coordinate, I compare with the last one and only set a small change. It worked better than before, but still kind of shitty.
|
Having the same problem. Any solutions on this? |
+1 |
1 similar comment
+1 |
I haven't tested it @tianhaoz95, but you could use lodash.debounce (with It's less than ideal, but I think I'm going to keep track of
And setup my Mapview such that scrollEnabled is always enabled for Android and for iOS right now scrollEnabled is the opposite of
Where |
@tianhaoz95 I've tried your solution but PID still has some margin of errors, which is not ideal until we have figured out the precise formula. I have then implemented my own solution. It works exactly as I want. Let the component know users are interacting with the map, inject this prop into the Map component. where Instead of using onPanDrag that updates hundreds of times (it's worse if you do this to state), we can simply get the
Then have your
Programmatically update the map, And yeah, since we are programmatically updating the map, @yaronlevi To implement the follow user method, just have your switch button subscribe to this, hope it helps.
|
But why |
How come this is still not addressed, I still have this problem. It's almost been a year. |
I'm having this issue now. Any workaround that doesn't involve redux? |
for me, instead of using onPanDrag, I used onMoveShouldSetResponder.
My methods:
My state:
I found out that storing region on state doesnt work well. I hope this helps someone |
@otaviogaiao where do you find that prop |
When using react-navigation v3 |
@outaTiME you will need to disable gestures in React-Navigation |
@alvelig @christopherdro it seems this is an application design issue rather than a bug in the library itself, using state to manage high frequency update for complex components such as mapview itself is expected to have bad performance. I would suggest closing this issue |
@salah-ghanim i disable gestures and no luck probably something else =( |
@outaTiME I would suggest you create a new issue then with a sample project, I'm more than happy to take a look then. |
@outaTiME I'm having a similar problem. If I use a drawer navigator or a stack navigator, which both respond to gestures, then my |
@jerryryle I'm having the exact same issue as you. Only difference is that I rely on both Do you know what would the best way to detect touch start and touch end on MapView when displayed inside one of the GestureHandler 's from react-native-gesture-handler? |
@outaTiME @jerryryle @grifotv For me, onMoveShouldSetResponder works on Android, but not on iOS. I think this may be related to software-mansion/react-native-gesture-handler#255, where onMoveShouldSetResponder can't fire because the React-Native-Gesture-Handler panGestureHandler is still active. However, RNGH's panGestureHandler doesn't work with the map either as discussed in the issue @jerryryle referenced. Anyone found an efficient workaround? |
When the followUserLocation state turns true after the user finish dragging ? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I am trying to implement a simple "follow me" switch (like Google Maps).
When the switch is ON, the map region is automatically updated every couple of seconds and follows the user.
But when the user manually dose any drag gesture on the map, the switch will go to OFF mode and the map will not follow the user.
I used onPanDrag to know when the user manually moves the map. On android it's working fine:
The code above works great: When the user drags the map, I set isFollowingUser to FALSE. Later in the geoLocationWatchPosition callback I see that isFollowingUser equals FALSE, and do not update the region to the new location.
But on iOS , I must set scrollEnabled:false in order make onPanDrag work. But now, because scrollEnabled is FALSE, the map won't move when the user interacts with it. So I tried to do this inside the onPanDrag:
The map moves, but it is barley usable. It's very slow and stutters. I think it is related to the fact that setState is called many times a second, but how can I do it otherwise?
The text was updated successfully, but these errors were encountered: