Represents the collection of tracks, keyframes and transitions that define an animation for the map.
public sealed class Animation
Public NotInheritable Class Animation
Set Animation Length
public void SetAnimationLength(TimeSpan length)
{
var mapView = MapView.Active;
if (mapView != null)
return;
var animation = mapView.Map.Animation;
var duration = animation.Duration;
if (duration == TimeSpan.Zero)
return;
var factor = length.TotalSeconds / duration.TotalSeconds;
animation.ScaleDuration(factor);
}
Scale Animation
public void ScaleAnimationAfterTime(TimeSpan afterTime, TimeSpan length)
{
var mapView = MapView.Active;
if (mapView != null)
return;
var animation = mapView.Map.Animation;
var duration = animation.Duration;
if (duration == TimeSpan.Zero || duration <= afterTime)
return;
var factor = length.TotalSeconds / (duration.TotalSeconds - afterTime.TotalSeconds);
animation.ScaleDuration(afterTime, duration, factor);
}
Camera Keyframes
public List<CameraKeyframe> GetCameraKeyframes()
{
var mapView = MapView.Active;
if (mapView != null)
return null;
var animation = mapView.Map.Animation;
var cameraTrack = animation.Tracks.OfType<CameraTrack>().First(); //There will always be only 1 CameraTrack in the animation.
return cameraTrack.Keyframes.OfType<CameraKeyframe>().ToList();
}
Create Camera Keyframe
public void CreateCameraKeyframe(TimeSpan atTime)
{
var mapView = MapView.Active;
if (mapView != null)
return;
var animation = mapView.Map.Animation;
var cameraTrack = animation.Tracks.OfType<CameraTrack>().First(); //There will always be only 1 CameraTrack in the animation.
cameraTrack.CreateKeyframe(mapView.Camera, atTime, ArcGIS.Core.CIM.AnimationTransition.FixedArc);
}
Create Time Keyframe
public void CreateTimeKeyframe(TimeSpan atTime)
{
var mapView = MapView.Active;
if (mapView != null)
return;
var animation = mapView.Map.Animation;
var timeTrack = animation.Tracks.OfType<TimeTrack>().First(); //There will always be only 1 TimeTrack in the animation.
timeTrack.CreateKeyframe(mapView.Time, atTime, ArcGIS.Core.CIM.AnimationTransition.Linear);
}
Create Range Keyframe
public void CreateRangeKeyframe(ArcGIS.Desktop.Mapping.Range range, TimeSpan atTime)
{
var mapView = MapView.Active;
if (mapView != null)
return;
var animation = mapView.Map.Animation;
var rangeTrack = animation.Tracks.OfType<RangeTrack>().First(); //There will always be only 1 RangeTrack in the animation.
rangeTrack.CreateKeyframe(range, atTime, ArcGIS.Core.CIM.AnimationTransition.Linear);
}
Create Layer Keyframe
public void CreateLayerKeyframe(Layer layer, double transparency, TimeSpan atTime)
{
var mapView = MapView.Active;
if (mapView != null)
return;
var animation = mapView.Map.Animation;
var layerTrack = animation.Tracks.OfType<LayerTrack>().First(); //There will always be only 1 LayerTrack in the animation.
layerTrack.CreateKeyframe(layer, atTime, true, transparency, ArcGIS.Core.CIM.AnimationTransition.Linear);
}
System.Object
ArcGIS.Desktop.Mapping.Animation
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.