四步简单入门:
1)首先在图层中增加TIME的时间字段。
2)再次增加:MAP的TimeExtent属性
<esri:Map x:Name="MyMap" TimeExtent="{Binding ElementName=MyTimeSlider, Path=Value}" Background="White" Grid.RowSpan="2" Cursor="Hand">
<esri:Map.Layers>
</esri:Map.Layers>
</esri:Map>
3)增加时间播放图层:
public void insertFeatureLayer()
{
ESRI.ArcGIS.Client.FeatureLayer NewTiledLayer = new FeatureLayer();
NewTiledLayer.Initialized += (evtsender, args) =>
{
datePicker1.Text= System.DateTime.Now.ToShortDateString();
TimeExtent extent = new TimeExtent(MyTimeSlider.MinimumValue, MyTimeSlider.MaximumValue);
MyTimeSlider.Intervals = TimeSlider.CreateTimeStopsByTimeInterval(extent, new TimeSpan(0, 1, 0, 0, 0));
this.TimerBar.Visibility = Visibility.Visible;
};
// for (int i = 0; i < tables[0].Length; i++)
NewTiledLayer.ID = "EarthquakesLayer";
NewTiledLayer.OutFields.Add("*");
NewTiledLayer.Url = "http://super/ArcGIS/rest/services/SX/MapServer/7";
NewTiledLayer.Renderer = this.MyTemporalRenderer ;
MyMap.Layers.Insert(indexlayer++, NewTiledLayer);
}4)renderer资源:
<esriSymbols:MarkerSymbol x:Name="DefaultMarkerSymbol" x:Key="DefaultMarkerSymbol">
<esriSymbols:MarkerSymbol.ControlTemplate>
<ControlTemplate>
<Canvas>
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="CommonStates">
<vsm:VisualState x:Name="MouseOver">
<Storyboard RepeatBehavior="ForEver">
<DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" From="1" To="10" Duration="00:00:01" />
<DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" From="1" To="10" Duration="00:00:01" />
<DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)" From="1" To="0" Duration="00:00:01" />
</Storyboard>
</vsm:VisualState>
<VisualState x:Name="Normal">
<Storyboard RepeatBehavior="ForEver">
<DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" From="1" To="3" Duration="00:00:01" />
<DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" From="1" To="3" Duration="00:00:01" />
<DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)" From="1" To="0" Duration="00:00:01" />
</Storyboard>
</VisualState>
</vsm:VisualStateGroup>
</vsm:VisualStateManager.VisualStateGroups>
<Ellipse Height="6" Width="6" Canvas.Left="-3" Canvas.Top="-3" RenderTransformOrigin="0.5,0.5" x:Name="ellipse" IsHitTestVisible="False">
<Ellipse.RenderTransform>
<ScaleTransform />
</Ellipse.RenderTransform>
<Ellipse.Fill>
<RadialGradientBrush>
<GradientStop Color="#00FF0000" />
<GradientStop Color="#FFFF0000" Offset="0.25" />
<GradientStop Color="#00FF0000" Offset="0.5" />
<GradientStop Color="#FFFF0000" Offset="0.75" />
<GradientStop Color="#00FF0000" Offset="1" />
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Ellipse Height="6" Width="6" Canvas.Left="-3" Canvas.Top="-3" Fill="#FFFF0000" x:Name="ellipse1" />
</Canvas>
</ControlTemplate>
</esriSymbols:MarkerSymbol.ControlTemplate>
</esriSymbols:MarkerSymbol>
<esriSymbols:SimpleMarkerSymbol x:Name="MySmallMarker" x:Key="MySmallMarkerSymbol" Size="8" >
<esriSymbols:SimpleMarkerSymbol.Color>
<RadialGradientBrush>
<GradientStop Color="Yellow" Offset="0.778"/>
<GradientStop Color="#FF0E0D07" Offset="1"/>
</RadialGradientBrush>
</esriSymbols:SimpleMarkerSymbol.Color>
</esriSymbols:SimpleMarkerSymbol>
<esriSymbols:MarkerSymbol x:Key="ResonateMarkerSymbol">
<esriSymbols:MarkerSymbol.ControlTemplate>
<ControlTemplate>
<Canvas>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<Storyboard RepeatBehavior="Forever">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Offset)" Storyboard.TargetName="ellipse">
<EasingDoubleKeyFrame KeyTime="0" Value="0.372"/>
<EasingDoubleKeyFrame KeyTime="0:0:00.5" Value="0.453"/>
<EasingDoubleKeyFrame KeyTime="0:0:01" Value="0.704"/>
<EasingDoubleKeyFrame KeyTime="0:0:01.5" Value="0.968"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[4].(GradientStop.Offset)" Storyboard.TargetName="ellipse">
<EasingDoubleKeyFrame KeyTime="0:0:00.5" Value="0.58"/>
<EasingDoubleKeyFrame KeyTime="0:0:01" Value="0.784"/>
<EasingDoubleKeyFrame KeyTime="0:0:01.5" Value="0.992"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimation BeginTime="0"
Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)"
From="1" To="0" Duration="0:0:01.5" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Ellipse x:Name="ellipse" Height="70" StrokeThickness="3" Width="70"
Canvas.Left="-35" Canvas.Top="-35">
<Ellipse.Fill>
<RadialGradientBrush>
<GradientStop Color="#FFC82727"/>
<GradientStop Color="#FF141413" Offset="0.255"/>
<GradientStop Color="#FF700C0B" Offset="0.115"/>
<GradientStop Color="#D3373433" Offset="0.381"/>
<GradientStop Color="#00F3EBE9" Offset="0.667"/>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Rectangle x:Name="rectangle" Width="20" Height="20" Canvas.Left="-10" Canvas.Top="-10"
IsHitTestVisible="False">
<Rectangle.Fill>
<ImageBrush ImageSource="flag-red-16x16.png" />
</Rectangle.Fill>
</Rectangle>
</Canvas>
</ControlTemplate>
</esriSymbols:MarkerSymbol.ControlTemplate>
</esriSymbols:MarkerSymbol>
<esriSymbols:SimpleLineSymbol x:Key="TracklineSymbol" Color="Black" Width="1" Style="Dash" />
<!-- Temporal renderer -->
<esri:TemporalRenderer x:Name="MyTemporalRenderer" x:Key="MyTemporalRenderer" TrackIdField="队伍编号">
<esri:TemporalRenderer.LatestObservationRenderer>
<esri:SimpleRenderer Symbol="{StaticResource ResonateMarkerSymbol}" />
</esri:TemporalRenderer.LatestObservationRenderer>
<esri:TemporalRenderer.ObservationRenderer>
<esri:SimpleRenderer Symbol="{StaticResource DefaultMarkerSymbol}" />
</esri:TemporalRenderer.ObservationRenderer>
<esri:TemporalRenderer.TrackRenderer>
<esri:SimpleRenderer Symbol="{StaticResource TracklineSymbol}" />
</esri:TemporalRenderer.TrackRenderer>
<esri:TemporalRenderer.SymbolAger>
<esri:RampInterpolator>
<esri:RampInterpolator.OpacityRange>
<esri:OpacityRange From="1" To=".1" />
</esri:RampInterpolator.OpacityRange>
</esri:RampInterpolator>
</esri:TemporalRenderer.SymbolAger>
</esri:TemporalRenderer>