Fork me on GitHub
Show:

AutoUpdateAnimation

Summary

An AutoUpdateAnimation is automatically updated to to display the most current tiles available from the Aeris API.

The timespan (to - from) of an AutoUpdateAnimation object will always remain constant.

For example:

var animation = new AutoUpdateAnimation({ from: 1PM_TODAY to: 3PM_TODAY });

// Some time passes... // Tiles become available for 4PM_TODAY animation.getTo(); // 4PM_TODAY animation.getFrom(); // 2PM_TODAY

Note that as the animation range is updated, it will trigger 'change:from' and 'change:to' events. This is useful if you need UI components to reflect the range of the animation.

animation.on('change:from change:to', function() { $('#rangeInput').attr('min', animation.getFrom().getTime()); $('#rangeInput').attr('max', animation.getFrom().getTime()); });

Constructor

aeris.maps.animations.AutoUpdateAnimation

Syntax

aeris.maps.animations.AutoUpdateAnimation

()

Summary

Methods

bindToLayerAutoUpdate_

Syntax

bindToLayerAutoUpdate_

() private

Summary

destroy

Syntax

destroy

()

Summary

Destroys the tile animation object, clears animation frames from memory.

getClosestTime_

Syntax

getClosestTime_

(
  • targetTime
  • opt_times
)
Number private

Summary

Returns the closes available time.

Parameters:

  • targetTime Number

    UNIX timestamp.

  • opt_times Array.<Number>

    Defaults to loaded animation times.

Returns:

getClosestTimeInSameTense_

Syntax

getClosestTimeInSameTense_

(
  • targetTime
  • opt_times
)
Number private

Summary

Returns the closes available time.

If provided time is in the past, will return the closest past time (and vice versa);

Parameters:

  • targetTime Number

    UNIX timestamp.

  • opt_times Array.<Number>

    Defaults to loaded animation times.

Returns:

getCurrentTime

Syntax

getCurrentTime

() ?Date

Summary

Returns:

?Date:

getFrom

Syntax

getFrom

() Date

Summary

Returns:

Date:

getLayerForTimeInSameTense_

Syntax

getLayerForTimeInSameTense_

(
  • time
)
AerisTile private

Summary

Parameters:

Returns:

getLayerIndex_

Syntax

getLayerIndex_

() Number private

Summary

Returns the index of the current layer within this.times_.

Returns:

getLoadProgress

Syntax

getLoadProgress

() Number

Summary

Returns:

Number:

Percentage complete loading tile (1.0 is 100% complete).

getTimes

Syntax

getTimes

() Array.<number>

Summary

Returns available times. Note that times are loaded asynchronously from the Aeris Interactive Tiles API, so they will not be immediately available.

Wait for the 'load:times' event to fire before attempting to grab times.

Returns:

Array.<number>:

An array timestamps for which they are available tile frames.

getTo

Syntax

getTo

()

Summary

goToTime

Syntax

goToTime

(
  • time
)

Summary

Animates to the layer at the specified time.

If no layer exists at the exact time specified, will use the closest available time.

Parameters:

hasMap

Syntax

hasMap

()

Summary

isAnimating

Syntax

isAnimating

() Boolean

Summary

Returns:

Boolean:

True, if the animation is currently running.

isCurrentLayer_

Syntax

isCurrentLayer_

(
  • layer
)
Boolean private

Summary

Parameters:

Returns:

isCurrentLayerFirst_

Syntax

isCurrentLayerFirst_

() Boolean private

Summary

Returns:

Boolean:

True, if the current layer is the first frame.

isCurrentLayerLast_

Syntax

isCurrentLayerLast_

() Boolean private

Summary

Returns:

Boolean:

True, if the current layer is the last frame.

keepCurrentTimeInBounds_

Syntax

keepCurrentTimeInBounds_

() private

Summary

Makes sure that the current time is always within the from and to bounds of the animation.

loadAnimationLayers

Syntax

loadAnimationLayers

() Promise

Summary

Load the tile layers for the animation.

Returns:

Promise:

Promise to load all layers.

next

Syntax

next

()

Summary

Animates to the layer at the next available time, or loops back to the start.

normalizeTimeBounds_

Syntax

normalizeTimeBounds_

() private

Summary

pause

Syntax

pause

()

Summary

Stop animation the layer, and stay at the current frame.

preload

Syntax

preload

()

Summary

preloadLayer_

Syntax

preloadLayer_

(
  • layer
)
Promise private

Summary

Preloads a single tile layer.

Parameters:

Returns:

Promise:

Promise to load the layer

previous

Syntax

previous

()

Summary

Animates to the previous layer, or loops back to the last layer.

refreshCurrentLayer_

Syntax

refreshCurrentLayer_

() private

Summary

setFrom

Syntax

setFrom

(
  • from
)

Summary

Parameters:

setSpeed

Syntax

setSpeed

(
  • speed
)

Summary

Set the animation speed.

Every second, [timestep] * [speed] milliseconds of tiles are animated.

So with a timestep of 360,000 (6 minutes), and a speed of 2: every second, 12 minutes of tiles will be animated.

Setting a negative speed will cause the animation to run in reverse.

Also see {aeris.maps.animations.AbstractAnimation}#setTimestamp

Parameters:

setTimestep

Syntax

setTimestep

(
  • timestep
)

Summary

Sets the animation timestep.

See {aeris.maps.animations.AbstractAnimation}#setSpeed for more information on how to use setTimestep and setSpeed to affect your animation speed.

Parameters:

  • timestep Number

    Timestep, in milliseconds.

setTo

Syntax

setTo

(
  • to
)

Summary

Parameters:

start

Syntax

start

()

Summary

Start animating the layer.

Every second, the layer is animated up by timestep * speed milliseconds.

stop

Syntax

stop

()

Summary

Stop animating the layer, and return to the most recent frame

syncLayerToMaster_

Syntax

syncLayerToMaster_

(
  • layer
)
private

Summary

Update the attributes of the provided layer to match those of the master layer.

Parameters:

transition_

Syntax

transition_

(
  • opt_oldLayer
  • newLayer
)
private

Summary

Transition from one layer to another.

Parameters:

transitionIn_

Syntax

transitionIn_

(
  • layer
)
private

Summary

Parameters:

transitionInClosestLoadedLayer_

Syntax

transitionInClosestLoadedLayer_

() private

Summary

transitionOut_

Syntax

transitionOut_

(
  • layer
)
private

Summary

Parameters:

transitionWhenLoaded_

Syntax

transitionWhenLoaded_

(
  • opt_oldLayer
  • newLayer
)
private

Summary

Handle transition for a layer which has not yet been loaded

Parameters:

Properties

animationClock_

Syntax

animationClock_

Number private

Summary

A reference to the timer created by window.setInterval

currentLayer_

Syntax

currentLayer_

?aeris.maps.layers.AerisTile private

Summary

currentTime_

Syntax

currentTime_

Number Timestamp private

Summary

The time of the current animation frame.

endDelay_

Syntax

endDelay_

number Milliseconds. private

Summary

Time to wait before repeating animation loop.

from_

Syntax

from_

Date protected

Summary

Animation start time.

layersByTime_

Syntax

layersByTime_

Object. private

Summary

A hash of {aeris.maps.layers.AerisTile}, listed by timestamp.

limit_

Syntax

limit_

Number protected

Summary

Max number of time "frames" to load and render.

masterLayer_

Syntax

masterLayer_

aeris.maps.layers.AerisTile private

Summary

The original layer object, which will serve as the 'master' for all animation layer "frames."

speed_

Syntax

speed_

Number private

Summary

Number of minutes of weather data to display within a second.

times_

Syntax

times_

Array.number private

Summary

An array of available timestamps.

timestep_

Syntax

timestep_

Number private

Summary

Milliseconds between animation frames.

to_

Syntax

to_

Date protected

Summary

Animation end time.

Default: Current time.

Events

autoUpdate

Syntax

autoUpdate

Summary

change:from

Syntax

change:from

Summary

Event Payload:

change:time

Syntax

change:time

Summary

When current time of the animation changes.

Event Payload:

change:to

Syntax

change:to

Summary

Event Payload:

load:complete

Syntax

load:complete

Summary

Fires when all animation tile frames are loaded.

Waiting to start an animation until this event is triggered will ensure smooth animations.

If an animation is started before all tile frames are loaded, tiles which are not yet loaded will not render until they are loaded.

load:error

Syntax

load:error

Summary

Event Payload:

load:progress

Syntax

load:progress

Summary

Fires to indicate progress in preloading tiles.

Useful for rendering loading UI to the user, or if you want to buffer an animation to a certain % done.

Event Payload:

  • Percent Number

    complete (where 1.0 is 100%).

load:times

Syntax

load:times

Summary

Fires when tile times are loaded for this animation.

Event Payload:

  • A Array.

    list of timestamps. for which animation frames will be created.