MaplyViewControllerAnimationDelegate

Objective-C

@protocol MaplyViewControllerAnimationDelegate <NSObject>

Swift

protocol MaplyViewControllerAnimationDelegate : NSObjectProtocol

An animation delegate that can be set on a MaplyViewController to control the view over time.

Filling out these methods will get you animation callbacks at the proper time to control position, heading and height on a frame basis.

You pass the resulting object in to

  • This method is called when the animation starts.

    At the animation start we collect up the various parameters of the current visual view state and pas them in via the startState. You probably want to keep track of this for later.

    Declaration

    Objective-C

    - (void)mapViewController:(MaplyViewController *_Nonnull)viewC
                   startState:
                       (MaplyViewControllerAnimationState *_Nonnull)startState
                    startTime:(NSTimeInterval)startTime
                      endTime:(NSTimeInterval)endTime;

    Swift

    func mapViewController(_ viewC: MaplyViewController, start startState: MaplyViewControllerAnimationState, startTime: TimeInterval, endTime: TimeInterval)

    Parameters

    viewC

    The view controller doing the animation.

    startState

    The starting point for the visual view animation. Cache this somewhere for your own interpolation.

    startTime

    When the animation starts (e.g. now)

    endTime

    When the animation ends. This is an absolute value.

  • This method is called at the beginning of every frame draw to position the viewer.

    This is the method that does all the work. You need to fill out the returned MaplyViewControllerAnimationState according to whatever interpolation your'e doing based on the currentTime.

    Declaration

    Objective-C

    - (nonnull MaplyViewControllerAnimationState *)
        mapViewController:(MaplyViewController *_Nonnull)viewC
             stateForTime:(NSTimeInterval)currentTime;

    Swift

    func mapViewController(_ viewC: MaplyViewController, stateForTime currentTime: TimeInterval) -> MaplyViewControllerAnimationState

    Parameters

    viewC

    The view controller doing the animation.

    currentTime

    The time for this frame. Use this rather than calculating the time yourself.

    Return Value

    The MaplyViewControllerAnimationState expressing where you want the viewer to be and where they are looking.

  • This method is called at the end of the animation.

    The map view controller calls this method when the animation is finished. Do your cleanup here if need be.

    Declaration

    Objective-C

    - (void)mapViewControllerDidFinishAnimation:
        (MaplyViewController *_Nonnull)viewC;

    Swift

    optional func mapViewControllerDidFinishAnimation(_ viewC: MaplyViewController)

    Parameters

    viewC

    The map view controller.