Open cmahopper opened 5 years ago
Setting padding is another animation triggered. To combine this to the same animation (with benefit of seeing also padding animating during the animation), please try use one of getCameraForGeometry methods with padding parameter, to get CameraPosition. We don't have the padding field exposed in the API, though so I need to verify this would work.
@astojilj Thanks, I'll take a look at them!
@astojilj Unfortunately, this is not quite what I'm looking for.
The function getCameraForGeometry
is just another way to get a CameraPosition.
I realize I didn't describe my problem clearly enough so that's my fault.
I'm starting a camera animation that zooms out to fit a route on the screen. While the camera is moving, something happens on the screen, like a BottomSheet slides up/down or changes size, and I want to change the padding on the MapboxMap, not just the camera animation. When changing the padding, the camera animation just stops.
I'm also not told by the CancelableCallback that the animation was cancelled, but that's another problem.
Thanks for the report @cmahopper! Like @astojilj mentioned, setting the padding will start a new camera animation that adapts the camera position to the requested padding. We should still deliver onCancel()
in this scenario, but otherwise, an interruption is expected here.
Thanks for the response @LukasPaczos.
I figured this was probably the case. Do you happen to have a suggestion for how to handle my case?
The workaround I am trying now is if padding needs to be updated while an animation is in progress, I wait until the animation is finished before setting the padding. Unfortunately, this causes the map to jump a little bit when the animation is done since I can't call MapboxMap#setPadding()
with an animation.
You could try using an Animator
to smoothly set padding values (which will result in a smooth animation) instead of setting it right away.
@LukasPaczos Right, I guess that'll have to do :)
Calling
MapboxMap#setPadding( ... )
after callingMapboxMap#animateCamera( ... )
(oreaseCamera( ... )
) causes the camera animation to stop, and, if theCancelableCallback
is set,onFinish()
is called instead ofonCancel()
.Ideally I would expect that the camera animation would not be interrupted by calling
setPadding()
. Otherwise, I would expect thatonCancel()
would be called on the camera animation'sCancelableCallback
when the animation is interrupted.Configuration
Android versions: Android 9.0 Mapbox SDK versions: 8.2.0