-
-
Notifications
You must be signed in to change notification settings - Fork 847
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
Improve camera transitions and related map callbacks #1838
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is Move different from Flight? There are four transition options but I can only think of three ways for the camera to move (flight, ease, and linear). It seems like perhaps Move should be deprecated?
One possibility is that fly zooms out goes to destination then zooms in, while move probably would not do that. But I might be wrong about that.
Is there any appetite for using CameraAnimator more heavily, to optionally allow users to animate camera properties individually? Imagine, for instance, having continuous, frequent updates to the camera's lat/lon, while simultaneously performing a slow change to the zoom level. This would require a change in the API, and it would add complexity, but I think it would better represent what Mapbox v10 has to offer, and would also match one of the nice subtleties Apple Maps has during navigation.
Yes we can experiment with that, it's ok to have v10 specific features.
If |
And just to note, I can't work on this over the weekend, but I did discover a bug that causes changing the padding to make the camera jump around a bit. I need to look into it more, so maybe hold off on merging? |
Looks like from implementation For 'Ease' and For 'Flight' we're using And we'd mapped animation modes here: maps/javascript/components/Camera.js Lines 605 to 616 in f42cacc
So:
It would be great to came up with v10 specific API, that gives use flexible way to handle camera animations, and also Viewport api |
Hi - so I noticed some pretty big differences in RCTMGLCamera.swift between this PR and the main branch. Heres a simpler change off of the main branch that enables iOS padding. @mfazekas i defer to you on which or both you want to merge in. It also doesn't have the jerking issue that this PR has. |
@dorthwein Thanks! I made a comment in your PR, but for posterity: the reason for the extra complexity is to allow padding to animate. Just setting it on the camera does change the padding, but instantaneously, not smoothly. |
Moved to #1850. |
@mfazekas I think this is pretty good to go for iOS - see the example below. The bug I mentioned where the camera "jumps around a bit" was actually because the padding and the camera were able to transition with different easing curves, so I made some changes to pick an appropriate curve for each camera transition type. This also clarifies the animation modes on the native side to example.mov |
@mfazekas The important part of the last bunch of commits is updating the payload shape and fixing a bug where the visible bounds were not being correctly returned (this line returned the max bounds available to the camera), but I also took the chance to do some reorganization of No regressions or breaking API changes, everything is additive only. map.mov |
I discovered a bug where if you changed I believe this was handled on the native side pre-v10 by caching the previous camera state, but I always found that prone to bugs because it created multiple sources of truth (JS and native). In my opinion, it's strongly preferable to require that the
@mfazekas What is your thought about merging this? It's getting to be a pretty big PR and I wouldn't mind synchronizing with example.mov |
@naftalibeder this looks good, but unit tests are failing |
👍 |
|
@vcebotari what platform/SDK/version are you on? |
Aloha @vcebotari and @naftalibeder , ran into same issue with current main - but was easy to solve: manually set Maybe we should default the And let's add it to the docs as well :) Cheers and thanks for this PR! |
hi, it's iOS, thank's to @rastapasta , that was the problem, adding |
default: | ||
return MapboxGL.CameraModes.Ease; | ||
return MapboxGL.CameraModes.Move; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@naftalibeder this changes default to Move
from Ease
. I'd like to revert, as this breaks code like:
cameraRef.setCamera({heading: 60, zoomLevel: 13.5, animationDuration: 20000})
That was doing a an animation, now it doesn't do any animation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it’s a little confusing to have an animation mode that means “transition instantly“, but still allow specifying a duration.
What about deprecating (but still keeping for backward compatibility) move
, and relying on the animation duration entirely - so there would be fly, ease, and linear, and if you want an instantaneous transition, you just specify animationDuration=0
?
That would solve this particular “bug“, and I think make the API less prone to conflicts like this in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question was more about default. I don't think we should change default mode, unless we have strong arguments for that.
You're right that Move
/None
is redundant with animationDuration=0
. I don't feel very strongly about this. I think it's fine to add a warning when someone tries to use non zero animationDuration with Move
/None
and it's also fine to do what you've suggested, that is to treat any animationDuration=0
as move
, etc.
But we should support Move
in this version give warning that it will be removed in v11. Then it's fine to remove in v11.
Description
Continues #1833.
CameraAnimator
that allows for the padding animation to be stopped and started (to prevent overlapping animations that cause a jump). This is becausecamera.padding
does not appear to be directly animatable.toUpdateItem(stop:)
to make it clearer what object/values are being returned.Checklist
I formatted JS and TS files with runningyarn lint:fix
in the root folderyarn generate
in the root folderCHANGELOG.md
I updated the typings files (index.d.ts
)/example
)Video
example.mov
Discussion
Move
different fromFlight
? There are four transition options but I can only think of three ways for the camera to move (flight, ease, and linear). It seems like perhapsMove
should be deprecated?CameraAnimator
more heavily, to optionally allow users to animate camera properties individually? Imagine, for instance, having continuous, frequent updates to the camera's lat/lon, while simultaneously performing a slow change to the zoom level. This would require a change in the API, and it would add complexity, but I think it would better represent what Mapbox v10 has to offer, and would also match one of the nice subtleties Apple Maps has during navigation.