Skip to content
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

How to stop refreshing user location after first centering the map? #222

Closed
nbastoWM opened this issue Jan 5, 2016 · 5 comments
Closed

Comments

@nbastoWM
Copy link

nbastoWM commented Jan 5, 2016

On onRegionChange I add an annotation for the current location.
I use userTrackingMode={this.userTrackingMode.follow} but in Android the annotation is always changing in very small steps and I can't pan the map because it recenters immediately. In iOS it's fine, it centers the map where you are, in the beginning, but then I can pan and zoom.
If i set userTrackingMode to none I cannot center the map in my current location.
How can I center the map in my location only in the beginning but then allow the user to move the map?

@tobrun
Copy link
Contributor

tobrun commented Jan 6, 2016

@nbastoWM
thank you for reaching out and flagging this issue,
I have created a ticket for this in the upstream repo mapbox/mapbox-gl-native#3444.

@tobrun tobrun added the Android label Jan 6, 2016
@tobrun
Copy link
Contributor

tobrun commented Jan 19, 2016

This will land if update to android 3.0.1 in #249 lands.

@thibthibaut
Copy link

The problem is that the behavior of onRegionChange is not the same on Android and iOS. If you look at the doc, you'll see:
iOS : Fired when the map ends panning or zooming
Android : Fired when the map is panning or zooming
This is a problem because if you wanna use the same code for Android and iOS you have different behaviors.

@nbastoWM
Copy link
Author

It would be great if we could get the user location when the map launches to set the centerCoordinate, and set the userTrackingMode to none.

But there's currently some bug with the navigator.geolocation.getCurrentPosition and I don't find any method in mapbox to get the current location.

@dapetcu21
Copy link
Collaborator

3.0.1 landed a long time ago and this has been fixed since.

Also, since 5.0.0, userTrackingMode now acts as any controlled component would: You set it to follow and when the user starts panning, you receive onChangeUserTrackingMode and set it back to none (or whatever the callback gives you).

Closing this.

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

No branches or pull requests

4 participants