Skip to content

Setting cameraMode cancels animation #544

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

Closed
stoefln opened this issue May 30, 2018 · 6 comments · Fixed by #583
Closed

Setting cameraMode cancels animation #544

stoefln opened this issue May 30, 2018 · 6 comments · Fixed by #583
Labels
location-layer-plugin Issues that deal with the location layer module

Comments

@stoefln
Copy link

stoefln commented May 30, 2018

When switching from overview to navigation mode in my app, I need to tilt the camera (3d perspective when driving). Additionally we need to set the cameraMode to a different one. The problem is that the tilt animation gets canceled when setting the cameraMode. I tried to do one after the other, using the animation callback, but its not a working solution either: when the user switches between modes quickly, the cameraMode cancels even the following animation. Blocking the user for around a second to quickly switch back to the first mode works, but it's not providing a good UX.
Is there an easier way to do this / am I missing something?
It seems to me that setting cameraMode is an asynchronous task, which takes some time. In this case there should be a callback available IMO.

A similar issue is that the animation gets cancelled on location update. How can this be avoided?

@LukasPaczos LukasPaczos added the location-layer-plugin Issues that deal with the location layer module label May 30, 2018
@LukasPaczos
Copy link
Contributor

In order to mix-up camera tracking with any other type of animation at the same time, you'll have to implement AndroidAnimators value animation and push updates through MapboxMap#moveCamera. We will try to make this easier by updating the camera tracking API itself or taking a different approach with the Camera Animator Plugin.

@1ec5
Copy link
Contributor

1ec5 commented Jun 5, 2018

updating the camera tracking API itself

mapbox/mapbox-gl-native#3625

@LukasPaczos LukasPaczos added this to the location-layer-0.6.0 milestone Jun 6, 2018
@LukasPaczos
Copy link
Contributor

Clearing up the issue - currently, the developer is unable to use Mapbox's camera API to move, zoom or tilt the camera while the plugin's camera tracking is engaged because it will cancel those animations.

Changing the camera position can be easily worked around by disengaging the tracking and working with MapboxMap#CancelableCallback to synchronize the process.

However, there is no possibility to zoom or tilt the camera while tracking without disrupting the UX.

Beside #550, another approach to solve this issue would be introducing additional methods to the plugin that would zoom in/out and tilt the camera using AndroidAnimators. This won't raise concerns from #550 (comment) as we won't expose ways to manipulate camera's target. This would serve as a temporary workaround until there is a concrete resolution for mapbox/mapbox-gl-native#3625.

/cc @danesfeder @kkaefer @julianrex @tobrun

@stoefln
Copy link
Author

stoefln commented Mar 14, 2019

I know this is an old ticket, but I am again facing the same issue with the newest version of mapbox and the navigation sdk.
I am using locationComponent?.setLocationComponentEnabled(true) and locationComponent.cameraMode = CameraMode.TRACKING_GPS

On each navigation progress update I do a
mapboxMap!!.locationComponent.forceLocationUpdate(location).
I also try to move the camera via mapboxMap!!.animateCamera just like in the android navigation examples.
Unfortunatelly this animation get's cancelled.

Changing the camera position can be easily worked around by disengaging the tracking and working with MapboxMap#CancelableCallback to synchronize the process.

@LukasPaczos how would disengaging look like? Or is this done differently in newer mapbox versions?

@LukasPaczos
Copy link
Contributor

Hey @stoefln, would you mind linking the nav examples you have in mind? Are the introduced #tiltWhileTracking and #zoomWhileTracking not working as expected for you?

We've also introduced the OnLocationCameraTransitionListener which gets notified when the transition from non-tracking to tracking mode has finished, you can pass that listener to the setCameraMode method.

Generally, if you engage a tracking mode, the MapboxMap animations will be canceled, that's why if you need a custom transition animation, you need should call the MapboxMap#animateCamera with the current location as target, pass the cancelable callback and engage the tracking in the #onFinish.

If above info doesn't help, could you provide a code example of your issue and cut a new ticket in the https://github.com/mapbox/mapbox-gl-native repo? Thanks!

@stoefln
Copy link
Author

stoefln commented Mar 19, 2019

Thanks Lukas,
I figured that I can't use camera tracking mode in combination with the navigation (in the examples, the mapmatched coordinates of the navigation progress are used to set the camera location and the user location marker). In our own app we used tracking mode for the camera.
I was somehow not aware of the fact that those components are conflicting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
location-layer-plugin Issues that deal with the location layer module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants