ArcGIS API for Windows Phone - Library Reference
TimeDataCumulative Property
See Also  Example Send comments on this topic
ESRI.ArcGIS.Client.Tasks Namespace > TimeOption Class : TimeDataCumulative Property

Gets or sets a value indicating whether the features in a sub-layer of a time-enabled ArcGISDynamicMapServiceLayer will be based upon the TimeExtent.Start of the REST service.

Syntax

Visual Basic (Declaration) 
Public Property TimeDataCumulative As Boolean
C# 
public bool TimeDataCumulative {get; set;}

Remarks

If the TimeOption.TimeDataCumulative = True then the data in the ArcGISDynamicMapServiceLayer returned is based upon the TimeExtent.Start of the REST service. If the TimeOption.TimeDataCumulative = False then the data in the ArcGISDynamicMapServiceLayer returned is based upon TimeExtent.Start of the Map Control.

The ArcGISDynamicMapServiceLayer.LayerDefinitions take precedence over other data restriction techniques like those of the ArcGISDynamicMapServiceLayer.LayerTimeOptions. In other words, the ArcGISDynamicMapServiceLayer.LayerDefinitions acts to limit the data in the ArcGISDynamciMapServiceLayer that the ArcGISDynamicMapServiceLayer.LayerTimeOptions can operate on.

Example

How to use:

When the application loads all major earthquakes with a Magnitude greater than 8.0 since 1/1/1970 will be displayed. Choose the different TimeDataCumulative RadioButton options to see what effect occurs in the features being drawn in the Map (and their count). When TimeDataCumulative = True the data in the ArcGISDynamicMapServiceLayer returned is based upon the TimeExtent.Start of the REST service (which dates back to 1/1/1970) and will display 20 features. When TimeDataCumulatve = False then the data in the ArcGISDynamicMapServiceLayer returned is based upon TimeExtent.Start of the Map Control (which is set to 1/1/2000) and will display 9 features.

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.

Testing the TimeDataCumulative settings of ArcGISDynamicMapServiceLayer.LayerTimeOptions.

XAMLCopy Code
<Grid x:Name="LayoutRoot">
            
  <!-- Add a Map Control. -->
  <esri:Map Name="Map1" HorizontalAlignment="Left" VerticalAlignment="Top"   
            Margin="14,240,0,0" Height="350" Width="500" WrapAround="True">
    <esri:Map.Layers>
      <esri:LayerCollection>
        
        <!-- Add a backdrop ArcGISTiledMapServiceLayer. -->
        <esri:ArcGISTiledMapServiceLayer 
          Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer" />
         
        <!-- 
        Add an ArcGISDynamicMapServiceLayer. The layer displays major earthquakes since 1970. A LayerDefinition
        has been applied such that ONLY those earthquakes with a Magnitude greater than 8.0 will be drawn in 
        the Map. The Initialized event is wired up to display the TimeExtents for which the earthquakes 
        will be displayed as well as count of the number of occurances displayed in the Map. The 
        DisableClientCaching is set to true which means all Rendering logic will be handled on ArcGIS Server.
        The LayerDefinition takes precidence over other data restriction types of queries like the LayerTimeOptions.
        -->
        <esri:ArcGISDynamicMapServiceLayer ID="earthquakes" 
                  Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/Since_1970/MapServer"
                  DisableClientCaching="True" Initialized="ArcGISDynamicMapServiceLayer_Initialized">
          <esri:ArcGISDynamicMapServiceLayer.LayerDefinitions>
            <esri:LayerDefinition LayerID="0" Definition="Magnitude > 8"/>
          </esri:ArcGISDynamicMapServiceLayer.LayerDefinitions>
        </esri:ArcGISDynamicMapServiceLayer>
        
      </esri:LayerCollection>
    </esri:Map.Layers>
  </esri:Map>
  
  <!-- Display the TimeExtent information being used by the Map Control. -->
  <sdk:Label Height="21" HorizontalAlignment="Left" Margin="12,111,0,0" Name="Label_TimeExtent_Start" 
             VerticalAlignment="Top" Width="120" Content="Map.TimeExtent.Start:"/>
  <TextBox Height="23" HorizontalAlignment="Left" Margin="140,106,0,0" Name="TextBox_TimeExtent_Start" 
           VerticalAlignment="Top" Width="374" />
  <sdk:Label Height="21" HorizontalAlignment="Left" Margin="12,146,0,0" Name="Label_TimeExtent_End" 
             VerticalAlignment="Top" Width="120" Content="Map.TimeExtent.End:"/>
  <TextBox Height="23" HorizontalAlignment="Left" Margin="140,144,0,0" Name="TextBox_TimeExtent_End" 
           VerticalAlignment="Top" Width="374" />
  <TextBlock Height="23" HorizontalAlignment="Left" Margin="12,109,0,0" Name="TextBlock_Ignored" Visibility="Visible" 
             Text="---------------------------------------------- I G N O R E D --------------------------------------" 
             VerticalAlignment="Top" Width="502" Foreground="Red" FontFamily="Arial" FontSize="14"/>
  
  <!-- 
  Allow the user options to change the ArcGISDynamicMapServiceLayer's TimeDataCumulative settings.
  If TimeDataCumulative = True then the data in the ArcGISDynamicMapServiceLayer returned is based upon 
  the TimeExtent.Start of the REST service (which dates back to 1/1/1970).
  If TimeDataCumulative = False then the data in the ArcGISDynamicMapServiceLayer returned is based upon
  TimeExtent.Start of the Map Control (which is set to 1/1/2000). 
  -->
  <sdk:Label Height="22" HorizontalAlignment="Left" Margin="14,180,0,0" Name="Label_TimeDataCumulative" 
             VerticalAlignment="Top" Width="120" Content="TimeDataCumulative:" />
  <RadioButton Content="True" Height="16" HorizontalAlignment="Left" Margin="140,181,0,0" 
               Name="rb_TimeDataCumulative_True" VerticalAlignment="Top" IsChecked="True" />
  <RadioButton Content="False" Height="16" HorizontalAlignment="Left" Margin="191,181,0,0" 
               Name="rb_TimeDataCumulative_False" VerticalAlignment="Top" />
  
  <!--
  Display the number of features that are returned as a result of changing the ArcGISDynamicMapServiceLayer's 
  TimeDataCumulative options.
  -->
  <sdk:Label Content="Number of Features:" Height="23" HorizontalAlignment="Left" Margin="284,181,0,0" 
             Name="Label_NumberOfFeatures" VerticalAlignment="Top" Width="120" />
  <TextBox Height="23" HorizontalAlignment="Left" Margin="401,176,0,0" Name="TextBox_NumberOfFeatures" 
           VerticalAlignment="Top" Width="113" />
  
  <!-- Add a button to demonstrate changing the ArcGISDynamicServiceLayer's TimeDataCumulative options. -->
  <Button Content="Apply ArcGISDynamicMapServiceLayer.LayerTimeOptions" Height="23" HorizontalAlignment="Left" 
          Margin="14,207,0,0" Name="Button1" VerticalAlignment="Top" Width="500" Click="Button1_Click"/>
  
  <!-- Provide the instructions on how to use the sample code. -->
  <TextBlock Height="100" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="788" TextWrapping="Wrap" 
   Text="When the application loads all major earthquakes with a Magnitude greater than 8.0 since 1/1/1970 will be displayed. 
         Choose the different TimeDataCumulative RadioButton options to see what effect occurs in the features being drawn in 
         the Map (and their count). When TimeDataCumulative = True the data in the ArcGISDynamicMapServiceLayer returned is 
         based upon the TimeExtent.Start of the REST service (which dates back to 1/1/1970) and will display 20 features. 
         When TimeDataCumulatve = False then the data in the ArcGISDynamicMapServiceLayer returned is based upon 
         TimeExtent.Start of the Map Control (which is set to 1/1/2000) and will display 9 features." />
   
</Grid>
C#Copy Code
private void Button1_Click(object sender, System.Windows.RoutedEventArgs e)
{
  // Get the ArcGISDynamicMapServiceLayer.
  ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = null;
  myArcGISDynamicMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)(Map1.Layers["earthquakes"]);
  
  // Create a new LayerTimeOptionCollection object.
  ESRI.ArcGIS.Client.LayerTimeOptionCollection myLayerTimeOptionCollection = new ESRI.ArcGIS.Client.LayerTimeOptionCollection();
  
  // Create a new TimeOption object. You can have multiple TimeOption objects; one for each FeatureLayer in
  // the ArcGISDynamicMapServicelayer.
  ESRI.ArcGIS.Client.Tasks.TimeOption myTimeOption1 = new ESRI.ArcGIS.Client.Tasks.TimeOption();
  
  // This the Layer ID from REST. Although the .LayerID property accepts a string you need to give it the integer 
  // value of a specific FeatureLayer in the ArcGISDynamicMapServiceLayer. 
  myTimeOption1.LayerId = Convert.ToString(0);
  
  // Create some variables used to obtain a count of the number of features returned via a QueryTask. The QueryTask
  // will approximate the same SQL syntax that is used by the ArcGISDynamicMapServiceLayer's TimeDataCumulative Property.
  string mySqlQuery = null;
  string mySubLayer_LayerDefinition = myArcGISDynamicMapServiceLayer.LayerDefinitions(0).Definition;
  
  // If TimeDataCumulative = True then the data in the ArcGISDynamicMapServiceLayer returned is based upon 
  // the TimeExtent.Start of the REST service (which dates back to 1/1/1970).
  // If TimeDataCumulative = False then the data in the ArcGISDynamicMapServiceLayer returned is based upon
  // TimeExtent.Start of the Map Control (which is set to 1/1/2000). 
  if (rb_TimeDataCumulative_True.IsChecked == true)
  {
    myTimeOption1.TimeDataCumulative = true;
    //mySqlQuery = "Magnitude > 8"
    mySqlQuery = mySubLayer_LayerDefinition;
    TextBlock_Ignored.Visibility = Windows.Visibility.Visible;
  }
   else if (rb_TimeDataCumulative_False.IsChecked == true)
  {
    myTimeOption1.TimeDataCumulative = false;
    //mySqlQuery = "Magnitude > 8 AND Date_ > DATE '1/1/2001'"
    mySqlQuery = mySubLayer_LayerDefinition + " AND Date_ > DATE '" + TextBox_TimeExtent_Start.Text + "'";
    TextBlock_Ignored.Visibility = Windows.Visibility.Collapsed;
  }
  
  // Make use of the TimeOption settings.
  myTimeOption1.UseTime = true;
  
  // Add the various options for the TimeOption into the LayerTimeOptionCollection. Note: you could have multiple TimeOption
  // objects and set the various values independently -- i.e. the ArcGISDynamicMapServiceLayer could have multiple
  // FeatureLayers each that is Time enabled.
  myLayerTimeOptionCollection.Add(myTimeOption1);
  
  // Set the ArcGISDynamicMalServiceLayer.LayerTimeOptions to the custom LayerTimeOptionCollection.
  myArcGISDynamicMapServiceLayer.LayerTimeOptions = myLayerTimeOptionCollection;
  
  // Create a TimeExtent object based upon what the user specifies for a TimeExtent.Start and TimeExtent.End.
  ESRI.ArcGIS.Client.TimeExtent myTimeExtent = new ESRI.ArcGIS.Client.TimeExtent(Convert.ToDateTime(TextBox_TimeExtent_Start.Text), Convert.ToDateTime(TextBox_TimeExtent_End.Text));
  
  // Set the Map.TimeExtent which will cause the ArcGISDynamicMapServiceLayer to re-render based upon the
  // new TimeExtent values.
  Map1.TimeExtent = myTimeExtent;
  
  // Display the number of features being returned in the ArcGISDynamicMapServiceLayer.
  GetFeatureCount(mySqlQuery);
}
  
private void ArcGISDynamicMapServiceLayer_Initialized(object sender, System.EventArgs e)
{
  
  // Set the values that the Map Control will use for the TimeExtent.
  TextBox_TimeExtent_Start.Text = Convert.ToString(new DateTime(2000, 1, 1));
  TextBox_TimeExtent_End.Text = Convert.ToString(DateTime.Today);
  
  // Create a SQL query that will perform QueryTask that approximates the same SQL syntax that is used by 
  // the ArcGISDynamicMapServiceLayer's TimeDataCumulative Property.
  string mySqlQuery = null;
  ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)sender;
  string mySubLayer_LayerDefinition = myArcGISDynamicMapServiceLayer.LayerDefinitions(0).Definition;
  GetFeatureCount(mySubLayer_LayerDefinition);
}
  
private void GetFeatureCount(string sqlQuery)
{
  // This function approximates the same SQL syntax that is used by  the ArcGISDynamicMapServiceLayer's 
  // TimeDataCumulative Property and displays the feature count back to the user.
  
  // Get the ArcGISDynamicMapServicelayer.
  ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = null;
  myArcGISDynamicMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)(Map1.Layers["earthquakes"]);
  
  // Get the Url of the ArcGISDynamicMapServiceLayer. 
  string myUrl = myArcGISDynamicMapServiceLayer.Url;
  
  // Get the ID of the earthquakes sub-layer.
  int mySubLayerID = myArcGISDynamicMapServiceLayer.Layers(0).ID;
  
  // Create a Query. Use the Map's Extent and SpatialReference. Return all the fields. 
  ESRI.ArcGIS.Client.Tasks.Query myQuery = new ESRI.ArcGIS.Client.Tasks.Query();
  myQuery.Geometry = Map1.Extent;
  myQuery.OutSpatialReference = Map1.SpatialReference;
  myQuery.OutFields.Add("*");
  myQuery.Where = sqlQuery;
  
  // Create a QueryTask using the correct Url and Query Parameters.
  ESRI.ArcGIS.Client.Tasks.QueryTask myQueryTask = new ESRI.ArcGIS.Client.Tasks.QueryTask();
  //queryTask.Url = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/Since_1970/MapServer/0"
  myQueryTask.Url = myUrl + "/" + mySubLayerID.ToString();
  myQueryTask.ExecuteAsync(myQuery);
  
  // Add the Event Handler for the Asynchronous QueryTask request.
  myQueryTask.ExecuteCompleted += myQueryTask_ExecuteCompleted;
}
  
private void myQueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs e)
{
  // Check to ensure we have valid return results.
  if (e.FeatureSet == null)
  {
    return;
  }
  
  // Obtain a FeatureSet from the queryArgs returned from the web service.
  ESRI.ArcGIS.Client.Tasks.FeatureSet myFeatureSet = e.FeatureSet;
  
  // Get the Features from the FeatureSet.
  System.Collections.Generic.IList<ESRI.ArcGIS.Client.Graphic> myFeatures = myFeatureSet.Features;
  
  // Display the number of features returned from the QueryTask.
  int myCount = myFeatures.Count;
  TextBox_NumberOfFeatures.Text = myCount.ToString();
}
VB.NETCopy Code
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
  
  ' Get the ArcGISDynamicMapServiceLayer.
  Dim myArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer
  myArcGISDynamicMapServiceLayer = CType(Map1.Layers("earthquakes"), ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)
  
  ' Create a new LayerTimeOptionCollection object.
  Dim myLayerTimeOptionCollection As New ESRI.ArcGIS.Client.LayerTimeOptionCollection
  
  ' Create a new TimeOption object. You can have multiple TimeOption objects; one for each FeatureLayer in
  ' the ArcGISDynamicMapServicelayer.
  Dim myTimeOption1 As New ESRI.ArcGIS.Client.Tasks.TimeOption
  
  ' This the Layer ID from REST. Although the .LayerID property accepts a string you need to give it the integer 
  ' value of a specific FeatureLayer in the ArcGISDynamicMapServiceLayer. 
  myTimeOption1.LayerId = CStr(0)
  
  ' Create some variables used to obtain a count of the number of features returned via a QueryTask. The QueryTask
  ' will approximate the same SQL syntax that is used by the ArcGISDynamicMapServiceLayer's TimeDataCumulative Property.
  Dim mySqlQuery As String = Nothing
  Dim mySubLayer_LayerDefinition As String = myArcGISDynamicMapServiceLayer.LayerDefinitions(0).Definition
  
  ' If TimeDataCumulative = True then the data in the ArcGISDynamicMapServiceLayer returned is based upon 
  ' the TimeExtent.Start of the REST service (which dates back to 1/1/1970).
  ' If TimeDataCumulative = False then the data in the ArcGISDynamicMapServiceLayer returned is based upon
  ' TimeExtent.Start of the Map Control (which is set to 1/1/2000). 
  If rb_TimeDataCumulative_True.IsChecked = True Then
    myTimeOption1.TimeDataCumulative = True
    'mySqlQuery = "Magnitude > 8"
    mySqlQuery = mySubLayer_LayerDefinition
    TextBlock_Ignored.Visibility = Windows.Visibility.Visible
  ElseIf rb_TimeDataCumulative_False.IsChecked = True Then
    myTimeOption1.TimeDataCumulative = False
    'mySqlQuery = "Magnitude > 8 AND Date_ > DATE '1/1/2001'"
    mySqlQuery = mySubLayer_LayerDefinition + " AND Date_ > DATE '" + TextBox_TimeExtent_Start.Text + "'"
    TextBlock_Ignored.Visibility = Windows.Visibility.Collapsed
  End If
  
  ' Make use of the TimeOption settings.
  myTimeOption1.UseTime = True
  
  ' Add the various options for the TimeOption into the LayerTimeOptionCollection. Note: you could have multiple TimeOption
  ' objects and set the various values independently -- i.e. the ArcGISDynamicMapServiceLayer could have multiple
  ' FeatureLayers each that is Time enabled.
  myLayerTimeOptionCollection.Add(myTimeOption1)
  
  ' Set the ArcGISDynamicMalServiceLayer.LayerTimeOptions to the custom LayerTimeOptionCollection.
  myArcGISDynamicMapServiceLayer.LayerTimeOptions = myLayerTimeOptionCollection
  
  ' Create a TimeExtent object based upon what the user specifies for a TimeExtent.Start and TimeExtent.End.
  Dim myTimeExtent As New ESRI.ArcGIS.Client.TimeExtent(CDate(TextBox_TimeExtent_Start.Text), CDate(TextBox_TimeExtent_End.Text))
  
  ' Set the Map.TimeExtent which will cause the ArcGISDynamicMapServiceLayer to re-render based upon the
  ' new TimeExtent values.
  Map1.TimeExtent = myTimeExtent
  
  ' Display the number of features being returned in the ArcGISDynamicMapServiceLayer.
  GetFeatureCount(mySqlQuery)
  
End Sub
            
Private Sub ArcGISDynamicMapServiceLayer_Initialized(sender As System.Object, e As System.EventArgs)
  
  ' Set the values that the Map Control will use for the TimeExtent.
  TextBox_TimeExtent_Start.Text = CStr(New Date(2000, 1, 1))
  TextBox_TimeExtent_End.Text = CStr(Date.Today)
  
  ' Create a SQL query that will perform QueryTask that approximates the same SQL syntax that is used by 
  ' the ArcGISDynamicMapServiceLayer's TimeDataCumulative Property.
  Dim mySqlQuery As String = Nothing
  Dim myArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer = CType(sender, ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)
  Dim mySubLayer_LayerDefinition As String = myArcGISDynamicMapServiceLayer.LayerDefinitions(0).Definition
  GetFeatureCount(mySubLayer_LayerDefinition)
  
End Sub
            
Private Sub GetFeatureCount(sqlQuery As String)
  
  ' This function approximates the same SQL syntax that is used by  the ArcGISDynamicMapServiceLayer's 
  ' TimeDataCumulative Property and displays the feature count back to the user.
  
  ' Get the ArcGISDynamicMapServicelayer.
  Dim myArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer
  myArcGISDynamicMapServiceLayer = CType(Map1.Layers("earthquakes"), ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)
  
  ' Get the Url of the ArcGISDynamicMapServiceLayer. 
  Dim myUrl As String = myArcGISDynamicMapServiceLayer.Url
  
  ' Get the ID of the earthquakes sub-layer.
  Dim mySubLayerID As Integer = myArcGISDynamicMapServiceLayer.Layers(0).ID
  
  ' Create a Query. Use the Map's Extent and SpatialReference. Return all the fields. 
  Dim myQuery As New ESRI.ArcGIS.Client.Tasks.Query
  myQuery.Geometry = Map1.Extent
  myQuery.OutSpatialReference = Map1.SpatialReference
  myQuery.OutFields.Add("*")
  myQuery.Where = sqlQuery
  
  ' Create a QueryTask using the correct Url and Query Parameters.
  Dim myQueryTask As New ESRI.ArcGIS.Client.Tasks.QueryTask
  'queryTask.Url = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/Since_1970/MapServer/0"
  myQueryTask.Url = myUrl + "/" + mySubLayerID.ToString
  myQueryTask.ExecuteAsync(myQuery)
  
  ' Add the Event Handler for the Asynchronous QueryTask request.
  AddHandler myQueryTask.ExecuteCompleted, AddressOf myQueryTask_ExecuteCompleted
  
End Sub
  
Private Sub myQueryTask_ExecuteCompleted(sender As Object, e As ESRI.ArcGIS.Client.Tasks.QueryEventArgs)
  
  ' Check to ensure we have valid return results.
  If e.FeatureSet Is Nothing Then
    Return
  End If
  
  ' Obtain a FeatureSet from the queryArgs returned from the web service.
  Dim myFeatureSet As ESRI.ArcGIS.Client.Tasks.FeatureSet = e.FeatureSet
  
  ' Get the Features from the FeatureSet.
  Dim myFeatures As System.Collections.Generic.IList(Of ESRI.ArcGIS.Client.Graphic) = myFeatureSet.Features
  
  ' Display the number of features returned from the QueryTask.
  Dim myCount As Integer = myFeatures.Count
  TextBox_NumberOfFeatures.Text = myCount.ToString
  
End Sub

Requirements

Target Platforms:Windows Phone 7

See Also

© ESRI, Inc. All Rights Reserved.