Visual Basic (Declaration) | |
---|---|
Public ReadOnly Property TimeExtent As TimeExtent |
C# | |
---|---|
public TimeExtent TimeExtent {get;} |
Only supported for ArcGIS Server from version 10.0 and onward.
The TimeExtent Property provides metadata about the ArcGISDynamicMapServiceLayer’s service as a TimeExtent Object. A TimeExtent defines the temporal period for which a phenomenon is relevant. A TimeExtent can be relevant for a singular specific instance of time (example: Tuesday February 1, 2011 at 11:30 am) or a window of time (example: Tuesday February 1st 2011 at 11:30 am to Wednesday February 2nd 2011 at 1:30 pm).
If temporal information is available (meaning it is not null/Nothing) for the geographic data in the ArcGISDynamicMapServiceLayer’s service, then developers can take advantage of using the Map.TimeExtent Property to display snapshots of the temporal data that covers a specified time period. When a geographic feature in the ArcGISDynamicMapServiceLayer has a TimeExtent and the Map Control its TimeExtent set, the feature will be rendered if it intersects the Map's TimeExtent. By adjusting the Map.TimeExtent users can see visually how a geographic phenomenon has changed over time. One analogy you can think of is that the Map.TimeExtent is like a window in a house. Depending on the size of the window, allows how much you can see outside (i.e. the features in the ArcGISDynamicMapServiceLayer). See the visual analogy depiction.
One common use case is to bind a TimeSlider Control with the a Map Control to provide an interactive user experience of showing how geographic temporal data changes over time. The TimeSlider Control is a User Interface (UI) control that looks and acts very similar to the buttons that one would find on a DVD or MP3 player. The TimeSlider emits TimeExtent values that are typically used in conjunction with the Map Control to enhance the viewing of geographic features that have attributes based upon Date/Time information. In most circumstances, the TimeSlider.Value Property is bound to the Map.TimeExtent Property to control the visible geographic features in a Layer that have temporal data.
It is possible to control the temporal information returned for individual sub-layers within the ArcGISDynamicMapServiceLayer by using the ArcGISDynamicMapServiceLayer.LayerTimeOptions Property.
TIP: For the ArcGISDynamicMapServiceLayer you can tell if TimeExtent information is available for the web service by copying the Url into the address bar of a web browser and scrolling through the ArcGIS Server web service description and look for a 'Time Info' section. See the following screen shot for an ArcGISDynamicMapServiceLayer:
In order to have an ArcGISDynamicMapServiceLayer with TimeExtent information, in ArcMap there must be at least one field in the layer for the published web service that is of type Date. This Date field must contain valid date/time information and have the Enable time on this layer checkbox turned on in the Time tab of the Layer Properties dialog. In ArcMap to launch the Layer Properties dialog, right click on the layer name in the Table of Contents and choose Properties... from the content menu. The following screen shot gives an example of the Layer Properties dialog where a Date field called 'Date_' is has the Enable time on this layer checkbox enabled:
How to use:
Click the button to initialize the TimeSlider functions (play, pause, forward, back) to display features in the ArcGISDynamicMapServiceLayer with TimeExtent Properties set.
The XAML code in this example is used in conjunction with the code-behind (C# or VB.NET) to demonstrate the functionality.
The following screen shot corresponds to the code example in this page.
XAML | Copy Code |
---|---|
<Grid x:Name="LayoutRoot"> <!-- Add a Map Control and set the initial extent to geographic area of Japan. --> <esri:Map Background="White" HorizontalAlignment="Left" Margin="0,162,0,0" Name="Map1" VerticalAlignment="Top" Height="318" Width="311" TimeExtent="{Binding ElementName=MyTimeSlider, Path=Value}" Extent="14328024,3407052,17104629,5996380"> <!-- Add a backdrop ArcGISTiledMapServiceLayer for reference. --> <esri:ArcGISTiledMapServiceLayer ID="PhysicalTiledLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" /> <!-- Add an ArcGISDynamicMapServiceLayer that has temopral data enabled (i.e. it has TimeExtent information). Don't display any features in the ArcGISDynamicMapServiceLayer (i.e. Visible=False until the TimeSlider is fully initialized via the user clicking the Button and executing the code-behind logic. --> <esri:ArcGISDynamicMapServiceLayer ID="EarthquakesSince1970" Visible="False" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/Since_1970/MapServer"/> </esri:Map> <!-- Add a TimeSlider to control the display of what geographic features are displayed in the Map Control based upon a specified TimeExtent. In the case of this sample code, when the specific features of the ArcGISDynamicMapServiceLayer have a TimeExtent that falls within the Map.TimeExtent will they be displayed based upon the MyTimeSlider settings. --> <esri:TimeSlider x:Name="MyTimeSlider" Loop="True" PlaySpeed="0:0:0.1" TimeMode="CumulativeFromStart" Height="22" Margin="0,134,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="311" /> <!-- Provide the instructions on how to use the sample code. --> <TextBlock Height="69" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="455" TextWrapping="Wrap" Margin="12,12,0,0" Text="Click the button to initialize the TimeSlider functions (play, pause, forward, back) to display features in the ArcGISDynamicMapServiceLayer with TimeExtent Properties set." /> <!-- Add a button to perform the work. --> <Button Content="Initialize the TimeSlider" Height="23" HorizontalAlignment="Left" Margin="0,105,0,0" Name="Button1" VerticalAlignment="Top" Width="311" Click="Button1_Click"/> </Grid> |
C# | Copy Code |
---|---|
private void Button1_Click(object sender, System.Windows.RoutedEventArgs e) { // This function sets up TimeSlider Intervals that define the tic marks along the TimeSlider track. Intervals // are a Collection of IEnumerable(Of Date) objects. When the TimeSlider.Intervals Property is set along with // the other necessary TimeSlider Properties, the full functionality of the TimeSlider is enabled. This full // functionality includes buttons for Play, Pause, Forward, and Back. // Get the ArcGISDynamicMapServiceLayer. ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = null; myArcGISDynamicMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)(Map1.Layers["EarthquakesSince1970"]); // Get the TimeExtent from the ArcGISDynamicMapServiceLayer. ESRI.ArcGIS.Client.TimeExtent myTimeExtent = myArcGISDynamicMapServiceLayer.TimeExtent; // Make sure we have valid ArcGISDynamicMapServiceLayer.TimeExtent information before trying to set up the TimeSlider. if (myTimeExtent != null) { // Get the Start (Minimum) and End (Maximum) dates from the ArcGISDyamicMapServiceLayer.TimeExtent. DateTime myMinimumDate = myTimeExtent.Start; DateTime myMaximumDate = myTimeExtent.End; // Set the TimeSlider .MinimumValue and MaximumValue Properties. MyTimeSlider.MinimumValue = myMinimumDate; MyTimeSlider.MaximumValue = myMaximumDate; // Create a new TimeExtent based on a single instance of time for the TimeSlider.Value Property. ESRI.ArcGIS.Client.TimeExtent valueTimeExtent = new ESRI.ArcGIS.Client.TimeExtent(myMinimumDate); MyTimeSlider.Value = valueTimeExtent; // Enable features to be shown in the ArcGISDynamicMapServiceLayer. myArcGISDynamicMapServiceLayer.Visible = true; // Create a new TimeSpan (1 year (i.e. 365 days) in our case). TimeSpan myTimeSpan = new TimeSpan(365, 0, 0, 0); // Create an empty Collection of IEnumerable(Of Date) objects. System.Collections.Generic.IEnumerable<DateTime> myIEnumerableDates = null; // Load all of Dates into the Collection of IEnumerable(Of Date) objects using the // TimeSlider.CreateTimeStopsByTimeInterval Shared/Static function. myIEnumerableDates = ESRI.ArcGIS.Client.Toolkit.TimeSlider.CreateTimeStopsByTimeInterval(myTimeExtent, myTimeSpan); // Set the TimeSlider.Intervals which define the tic marks along the TimSlider track to the IEnumerable(Of Date) // objects. MyTimeSlider.Intervals = myIEnumerableDates; } } |
VB.NET | Copy Code |
---|---|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) ' This function sets up TimeSlider Intervals that define the tic marks along the TimeSlider track. Intervals ' are a Collection of IEnumerable(Of Date) objects. When the TimeSlider.Intervals Property is set along with ' the other necessary TimeSlider Properties, the full functionality of the TimeSlider is enabled. This full ' functionality includes buttons for Play, Pause, Forward, and Back. ' Get the ArcGISDynamicMapServiceLayer. Dim myArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = CType(Map1.Layers("EarthquakesSince1970"), ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer) ' Get the TimeExtent from the ArcGISDynamicMapServiceLayer. Dim myTimeExtent As ESRI.ArcGIS.Client.TimeExtent = myArcGISDynamicMapServiceLayer.TimeExtent ' Make sure we have valid ArcGISDynamicMapServiceLayer.TimeExtent information before trying to set up the TimeSlider. If myTimeExtent IsNot Nothing Then ' Get the Start (Minimum) and End (Maximum) dates from the ArcGISDyamicMapServiceLayer.TimeExtent. Dim myMinimumDate As Date = myTimeExtent.Start Dim myMaximumDate As Date = myTimeExtent.End ' Set the TimeSlider .MinimumValue and MaximumValue Properties. MyTimeSlider.MinimumValue = myMinimumDate MyTimeSlider.MaximumValue = myMaximumDate ' Create a new TimeExtent based on a single instance of time for the TimeSlider.Value Property. Dim valueTimeExtent As New ESRI.ArcGIS.Client.TimeExtent(myMinimumDate) MyTimeSlider.Value = valueTimeExtent ' Enable features to be shown in the ArcGISDynamicMapServiceLayer. myArcGISDynamicMapServiceLayer.Visible = True ' Create a new TimeSpan (1 year (i.e. 365 days) in our case). Dim myTimeSpan As New TimeSpan(365, 0, 0, 0) ' Create an empty Collection of IEnumerable(Of Date) objects. Dim myIEnumerableDates As System.Collections.Generic.IEnumerable(Of Date) ' Load all of Dates into the Collection of IEnumerable(Of Date) objects using the ' TimeSlider.CreateTimeStopsByTimeInterval Shared/Static function. myIEnumerableDates = ESRI.ArcGIS.Client.Toolkit.TimeSlider.CreateTimeStopsByTimeInterval(myTimeExtent, myTimeSpan) ' Set the TimeSlider.Intervals which define the tic marks along the TimSlider track to the IEnumerable(Of Date) ' objects. MyTimeSlider.Intervals = myIEnumerableDates End If End Sub |
Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8