-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Mapbox Animating Camera #9808
Comments
@jfirebaugh Can we figure out a way to prefetch tiles using the platform based animations? |
mbgl currently treats |
I'm thinking of anchor as an animatable parameter. Setting this explicitly has been the easiest way to control the effect. I haven't given much thought to the tradeoffs of setting this implicitly. |
Currently, to change the camera’s padding (as the user perceives it), you’d need to reapply the current center coordinate with the new padding. The anchor is often provided by gesture recognizers (to be under the mouse cursor) when specifying a camera to animate to, but if you ask the map for its current anchor, you’ll always get an unset value. In this sense, If we were to keep the current |
That's a good point about the anchor moving to the point between touches on rotate. I'm very much thinking about this in the specific context of navigation where any touch/move on the map should cancel all animation. Any call to transition to the following mode (by tapping resume or re-center or using a timeout) should result in the anchor point moving to somewhere in the lower third of the screen. Calls for transition to the overhead view should move the anchor to the center of the defined viewport. |
See #9813 for cache eviction strategy when prefetching tiles. |
Capturing chat today (cc: @tobrun). Looks like |
Had a chat with @1ec5 yesterday. The plan is to experiment with using CoreAnimation to do camera animations without changing anything on core. |
This experiment would be focused specifically on one use case, a turn-by-turn navigation map view that only needs short-distance easing animations. The hope is that we can at least experiment with Core Animation integration purely at the SDK level. However, we’ll eventually need more from mbgl when we generalize this work to account for long-distance animations or flight animations. |
I did a quick test on Android. In gif below you can see two Android SDK animators running together to animate bearing and tilt independently. Above is created using the Android SDK animator framework: final NativeCameraPosition cameraPosition = mapView.getCameraPosition();
// Animate tilt
ValueAnimator tiltAnimator = ValueAnimator.ofFloat(0f, 60.0f);
tiltAnimator.setStartDelay(1000);
tiltAnimator.setDuration(4000);
tiltAnimator.setInterpolator(new FastOutSlowInInterpolator());
tiltAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
cameraPosition.setTilt(((Float) animation.getAnimatedValue()).doubleValue());
}
});
// Animate bearing
ValueAnimator bearingAnimator = ValueAnimator.ofFloat(0.0f, 160.0f);
bearingAnimator.setDuration(6000);
bearingAnimator.setInterpolator(new FastOutLinearInInterpolator());
bearingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
cameraPosition.setBearing(((Float)animation.getAnimatedValue()).doubleValue());
}
});
// Combine animations and start
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setStartDelay(1500);
animatorSet.play(tiltAnimator);
animatorSet.play(bearingAnimator);
animatorSet.start(); Note that I didn't change anything to core but I had to rework a couple of things in the android binding to make this work. Bringing a feature like this would mean increasing the API surface on the Android SDK. |
From core GL, we’ll mainly need to use |
Awesome to see this moving, tagging myself to follow along. |
PR unblocking this feature for the Android binding in #10001. |
Removing android label, API for that landed. |
Tagging myself and @fabian-guerra just for reference. |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
This is a ticket to track the discussion around implementing a new camera system for the various platforms.
The goal is to provide a camera system that allows independent animations to run on each of the map camera parameters. It should use a familiar API's for each of the platforms. This will give developers and designers the ability to have total control of the experience. It will also allow for the easy use of plug-in camera animation libraries and physics simulations for those who want to use certain styles of animation.
Further down the line, we should be able to introduce design tools for crafting animations and sharing those creations.
Some background and prior thinking:
“Fresh new camera”: mapbox/mapbox-gl-js#3583
“Concurrent Transition Animations”: #3625
“Reimplement camera transitions with Core Animation”: #8176
The new camera system will be able to animate each of the following parameters on independent timelines:
Animations will be handled on the various platforms and committed to the core with the frequency (or frame rate) controlled by the platform.
cc @mapbox/gl @pveugen
The text was updated successfully, but these errors were encountered: