This sample illustrates how to create a group animation in ArcMap. This sample only creates a group animation for two layers. However, it can be modified to work with three or more layers by adding more layers to the "LayerSet" property of the AGGroupAnimationOptions object.
How to use
- Open ArcMap and add two layers (feature or raster) to the ArcMap TOC;
- Copy and paste the following code into the VB editor in ArcMap;
- Make sure that "ESRI Animation Object Library" and "ESRI AnimationUI Object Library" are checked in the References dialog box of the VBA project;
- Run the macro "Create_Group_Animation";
- Click the Animation dropdown on the animation toolbar and click Animation Manager. In the Animation Manager dialog box, click the Tracks tab to verify that two new tracks have been created as a group animation.
Public Sub Create_Group_Animation()
'Find the animation extension
Dim pUID As New UID
pUID.Value = "esriAnimation.AnimationExtension"
Dim pAnimExt As IAnimationExtension
Set pAnimExt = Application.FindExtensionByCLSID(pUID)
'Create AGAnimationUtils
Dim pAGAnimUtils As IAGAnimationUtils
Set pAGAnimUtils = New AGAnimationUtils
Dim pAGGrpAnimOptions As IAGGroupAnimationOptions
Set pAGGrpAnimOptions = New AGGroupAnimationOptions
Set pAGGrpAnimOptions.AnimationEnvironment = pAnimExt.AnimationEnvironment
Set pAGGrpAnimOptions.AnimationTracks = pAnimExt.AnimationTracks
'Set the LayerSet property
Dim pArray As IArray
Set pArray = New esriSystem.Array
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Dim pMap As IMap
Set pMap = pMxDoc.Maps.Item(0)
pArray.Add pMap.Layer(0)
pArray.Add pMap.Layer(1)
Set pAGGrpAnimOptions.LayerSet = pArray
pAGGrpAnimOptions.OverwriteExisting = True
pAGGrpAnimOptions.TrackBaseName = "Sample group animation"
'Get map animation container from the extension
Dim pAnimContainer As IAGAnimationContainer
Set pAnimContainer = pAnimExt.AnimationTracks.AnimationObjectContainer
pAGAnimUtils.CreateLayerGroupAnimation pAnimContainer, pAGGrpAnimOptions
End Sub