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

Get or sets the TimeOption objects in a LayerTimeOptionCollection for each sub-layer in an ArcGISDynamicMapServiceLayer.

Syntax

Visual Basic (Declaration) 
Public Property LayerTimeOptions As LayerTimeOptionCollection
C# 
public LayerTimeOptionCollection LayerTimeOptions {get; set;}

Remarks

The TimeOption object indicates whether or not the sub-layer of an ArcGISDynamicMapServiceLayer should use the TimeExtent specified by the time parameter or not (see TimeOption.UseTime and LayerTimeOptionCollection), whether to draw the layer features cumulatively or not (see TimeOption.TimeDataCumulative), and if any time offsets will be used for the layer (see TimeOption.TimeOffset).

Using the Read/Get of the LayerTimeOptions Property returns null/Nothing unless it has been explicitly set by the developer (it is not automatically set as Property in the ArcGIS Server web service for the ArcGISDynamicMapServiceLayer). Developers need to create a new LayerTimeOptionCollection, add the TimeOption object(s) to it, and then set the new LayerTimeOptionCollection to the LayerTimeOptions Property. An ArcGISDynamicMapServiceLayer can have multiple TimeOption objects; one for each sub-layer in the ArcGISDynamicMapServiceLayer.

It is the Map.TimeExtent that controls what features are displayed based upon the temporal information in the ArcGISDynamicMapServiceLayer. The Map.TimeExtent acts as to limit the features displayed based upon the window-of-time specified by the TimeExtent.Start and TimeExtent.End. 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.

Analogy of how the Map.TimeExtent limits the temporal features being displayed in a layer is like looking out a window only allow certain visual images to be seen based upon the size of the window.

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

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.

If the TimeOption.UseTime = True then the data in the ArcGISDynamicMapServiceLayer returned is based upon occurrences between the TimeExtent.Start and TimeExtent.End of the Map Control. If the TimeOption.UseTime = False then time based queries are disabled for the ArcGISDynamicMapServiceLayer (meaning all of the records will be returned subject to any LayerDefinitons that may be set).

The TimeOption.LayerId is a String. Developers should cast the ArcGISDynamicMapServiceLayer.Layers.ID (an Integer) to a String when setting the TimeOption.LayerId.

Normally the Map.TimeExtent determines what features will be displayed for a time-enabled ArcGISDynamicMapServiceLayer. The TimeOption.TimeOffset is a special case where the features that are returned will be offset from what is specified in the Map.TimeExtent by the TimeOffset amount based upon specific TimeOption.TimeOffsetUnit denomination. Negative TimeOffset values are possible for returning features of previous times to the currently set Map.TimeExtent.

NOTE: A change was made to ArcGIS Server 10.02 (i.e. 10.0 Service Pack 2) and subsequents future versions that impacts what is needed to draw ALL features in an ArcGISDynamicMapServiceLayer that is time-enabled. Prior to ArcGIS Server 10.02, it was required in order to see the ALL features for a time-enabled ArcGISDynamicMapServiceLayer in a Map Control to either:
(1) set the Map.TimeExtent to a valid time that covered the features in the ArcGISDynamicMapServiceLayer
OR
(2) if no Map.TimeExtent was set on the Map Control, then each TimeOption for the sub-layer of the ArcGISDynamicMapServiceLayer needs to have the TimeOption.UseTime Property set to False.
As of ArcGIS Sever 10.02 and higher, the time-enabled ArcGISDynamicMapServiceLayer will automatically show ALL features, even if no Map.TimeExtent is set. See the code example in this document for a demonstration.

Example

How to use:

This sample demonstrates a change that was made to ArcGIS Server 10.02 (i.e. 10.0 Service Pack 2) and subsequents future versions that impacts what is needed to draw ALL features in an ArcGISDynamicMapServiceLayer that is time-enabled. Prior to ArcGIS Server 10.02, it was required in order to see the ALL features for a time-enabled ArcGISDynamicMapServiceLayer in a Map Control to either:
(1) set the Map.TimeExtent to a valid time that covered the features in the ArcGISDynamicMapServiceLayer
OR
(2) if no Map.TimeExtent was set on the Map Control, then each TimeOption for the sub-layer of the ArcGISDynamicMapServiceLayer needs to have the TimeOption.UseTime Property set to False.
As of ArcGIS Sever 10.02 and higher, the time-enabled ArcGISDynamicMapServiceLayer will automatically show ALL features, even if no Map.TimeExtent is 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.

Demonstrating changes that have occured in ArcGIS Server regarding time-enabled ArcGISDynamicMapServiceLayers.

XAMLCopy Code
<Grid x:Name="LayoutRoot" >
  
  <!-- Add a Map Control to the application. NOTE: There is NO TimeExtent Property specified! -->
  <esri:Map x:Name="Map1" WrapAround="True" HorizontalAlignment="Left" VerticalAlignment="Top" 
            Margin="0,238,0,0" Height="350" Width="450" />
  
  <!-- Add a Legend Control to demonstrate which features belong to which layers. -->
  <esri:Legend x:Name="MyLegend" Margin="456,238,0,0" Map="{Binding ElementName=Map1}" 
               Height="350" Width="250" VerticalAlignment="Top" HorizontalAlignment="Left"/>
    
  <!-- 
  Add a TextBox for the user to enter a Url for a time-enabled ArcGISDynamicMapServiceLayer and a Button
  for the user to click to add the layer to the Map Control.
  -->
  <sdk:Label Height="16" HorizontalAlignment="Left" Margin="0,184,0,0" Name="Label_Url" 
             VerticalAlignment="Top" Width="29" Content="Url:"/>
  <TextBox Height="23" HorizontalAlignment="Left" Margin="22,180,0,0" Name="TextBox_Url" VerticalAlignment="Top" 
           Width="684" 
           Text="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/StantonCountyKSLeases/MapServer"/>
  <Button Name="Button1" Height="23" HorizontalAlignment="Left" Margin="0,209,0,0"  VerticalAlignment="Top" 
          Width="706" 
          Click="Button1_Click" Content="Enter a Url for a 'time-enabled' ArcGISDynamicMapServiceLayer and click me."/>
  
  <!-- Provide the instructions on how to use the sample code. -->
  <TextBlock Height="174" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="788" TextWrapping="Wrap" 
   Text="This sample demonstrates a change that was made to ArcGIS Server 10.02 (i.e. 10.0 Service Pack 2) and subsequents 
         future versions that impacts what is needed to draw ALL features in an ArcGISDynamicMapServiceLayer that is 
         time-enabled. Prior to ArcGIS Server 10.02, it was required in order to see the ALL features for a time-enabled 
         ArcGISDynamicMapServiceLayer in a Map Control to either:
         (1) set the Map.TimeExtent to a valid time that covered the features in the ArcGISDynamicMapServiceLayer
         OR
         (2) if no Map.TimeExtent was set on the Map Control, then each TimeOption for the sub-layer of the 
         ArcGISDynamicMapServiceLayer needs to have the TimeOption.UseTime Property set to False.
          
         As of ArcGIS Sever 10.02 and higher, the time-enabled ArcGISDynamicMapServiceLayer will automatically show 
         ALL features, even if no Map.TimeExtent is set." />
         
</Grid>
C#Copy Code
private void Button1_Click(object sender, System.Windows.RoutedEventArgs e)
{
  // Create a new ArcGISDynamicMapServiceLayer using the Url from the TextBox on the UI page.
  ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = new ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer();
  myArcGISDynamicMapServiceLayer.ID = "myArcGISDynamicMapServiceLayer";
  myArcGISDynamicMapServiceLayer.Url = TextBox_Url.Text;
  
  // Wire-up the Initialized event handler so that Properties can be accessed and changed on the 
  // asynchronous ArcGISDynamicMapServiceLayer.
  myArcGISDynamicMapServiceLayer.Initialized += myArcGISDynamicMapServiceLayer_Initialized;
  
  // Add the ArcGISDynamicMapServiceLayer to the Map which will make the asynchronous call.
  Map1.Layers.Add(myArcGISDynamicMapServiceLayer);
}
  
private void myArcGISDynamicMapServiceLayer_Initialized(object sender, EventArgs e)
{
  // This function demonstrates a change that was made to ArcGIS Server 10.02 (i.e. 10.0 Service Pack 2) and what
  // is needed to draw ALL features in an ArcGISDynamicMapServiceLayer that is time-enabled.
  //
  // Prior to ArcGIS Server 10.02, it was required in order to see the ALL features for a time-enabled 
  // ArcGISDynamicMapServiceLayer in a Map Control to either:
  // (1) set the Map.TimeExtent to a valid time that covered the features in the ArcGISDynamicMapServiceLayer
  // OR
  // (2) if no Map.TimeExtent was set on the Map Control, then each TimeOption for the sub-layer of the 
  // ArcGISDynamicMapServiceLayer needs to have the TimeOption.UseTime Property set to False.
  // 
  // As of ArcGIS Sever 10.02 and higher, the time-enabled ArcGISDynamicMapServiceLayer will automatically show 
  // ALL features, even if no Map.TimeExtent is set.
  
  // Get the ArcGISDynamicMapServiceLayer and the Collection of LayerInfo objects (i.e. the sub-layers).
  ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)sender;
  ESRI.ArcGIS.Client.LayerInfo[] myLayerInfos = myArcGISDynamicMapServiceLayer.Layers;
  
  // Get the TimeExtent of the ArcGISDynamicMapServiceLayer.
  ESRI.ArcGIS.Client.TimeExtent myTimeExtent = myArcGISDynamicMapServiceLayer.TimeExtent;
  
  if (myTimeExtent != null)
  {
    //We have a time-enabled ArcGISDynamicMapServiceLayer.
    
    // Get the ArcGIS Server version that is serving up the ArcGISDynamicMapServiceLayer.
    double myVersion = myArcGISDynamicMapServiceLayer.Version;
    
    if (myVersion > 10.01)
    {
      // No need to do anything! The time-enabled ArcGISDynamicMapServiceLayer will draw all
      // features even though no Map.TimeExtent has been specified.
    }
    else
    {
      // Since we have an older version of ArcGIS Server, we need to make some adjustments in order to 
      // show ALL of the features in the time-enabled ArcGISDynamicMapServiceLayer when no Map.TimeExtent
      // has been specified. Uncomment/Comment out whichever version you want to try (they both produce 
      // the same results.
      
      // Option (1):
      // =====================================================================================
      // Set the Map.TimeExtent to that of the ArcGISDynamicMapServiceLayer.TimeExtent.
      //Map1.TimeExtent = myTimeExtent; 
      
      // Option (2):
      // =====================================================================================
      // Create a new LayerTimeOptionCollection.
      ESRI.ArcGIS.Client.LayerTimeOptionCollection myLayerTimeOptionCollection = new ESRI.ArcGIS.Client.LayerTimeOptionCollection();
      
      // Loop through each LayerInfo object.
      foreach (ESRI.ArcGIS.Client.LayerInfo myLayerInfo in myLayerInfos)
      {
        // Create a new TimeOption object and set the LayerID and UseTime Properties. Then add the
        // TimeOption to the LayerTimeOptionCollection.
        ESRI.ArcGIS.Client.Tasks.TimeOption myTimeOption = new ESRI.ArcGIS.Client.Tasks.TimeOption();
        myTimeOption.LayerId = Convert.ToString(myLayerInfo.ID);
        myTimeOption.UseTime = false;
        myLayerTimeOptionCollection.Add(myTimeOption);
      }
      
      // Set the ArcGISDynamicMapServiceLayer.LayerTimeOptions to the new custom LayerTimeOptionsCollection.
      myArcGISDynamicMapServiceLayer.LayerTimeOptions = myLayerTimeOptionCollection;
    }
  }
  else
  {
    //We do not have a time-enabled ArcGISDynamicMapServiceLayer. There is nothing to change.
  }
}
VB.NETCopy Code
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
            
  ' Create a new ArcGISDynamicMapServiceLayer using the Url from the TextBox on the UI page.
  Dim myArcGISDynamicMapServiceLayer As New ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer
  myArcGISDynamicMapServiceLayer.ID = "myArcGISDynamicMapServiceLayer"
  myArcGISDynamicMapServiceLayer.Url = TextBox_Url.Text
  
  ' Wire-up the Initialized event handler so that Properties can be accessed and changed on the 
  ' asynchronous ArcGISDynamicMapServiceLayer.
  AddHandler myArcGISDynamicMapServiceLayer.Initialized, AddressOf myArcGISDynamicMapServiceLayer_Initialized
  
  ' Add the ArcGISDynamicMapServiceLayer to the Map which will make the asynchronous call.
  Map1.Layers.Add(myArcGISDynamicMapServiceLayer)
  
End Sub
  
Private Sub myArcGISDynamicMapServiceLayer_Initialized(sender As Object, e As EventArgs)
  
  ' This function demonstrates a change that was made to ArcGIS Server 10.02 (i.e. 10.0 Service Pack 2) and what
  ' is needed to draw ALL features in an ArcGISDynamicMapServiceLayer that is time-enabled.
  '
  ' Prior to ArcGIS Server 10.02, it was required in order to see the ALL features for a time-enabled 
  ' ArcGISDynamicMapServiceLayer in a Map Control to either:
  ' (1) set the Map.TimeExtent to a valid time that covered the features in the ArcGISDynamicMapServiceLayer
  ' OR
  ' (2) if no Map.TimeExtent was set on the Map Control, then each TimeOption for the sub-layer of the 
  ' ArcGISDynamicMapServiceLayer needs to have the TimeOption.UseTime Property set to False.
  ' 
  ' As of ArcGIS Sever 10.02 and higher, the time-enabled ArcGISDynamicMapServiceLayer will automatically show 
  ' ALL features, even if no Map.TimeExtent is set.
  
  ' Get the ArcGISDynamicMapServiceLayer and the Collection of LayerInfo objects (i.e. the sub-layers).
  Dim myArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer = CType(sender, ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)
  Dim myLayerInfos As ESRI.ArcGIS.Client.LayerInfo() = myArcGISDynamicMapServiceLayer.Layers
   
  ' Get the TimeExtent of the ArcGISDynamicMapServiceLayer.
  Dim myTimeExtent As ESRI.ArcGIS.Client.TimeExtent = myArcGISDynamicMapServiceLayer.TimeExtent
  
  If myTimeExtent IsNot Nothing Then
    'We have a time-enabled ArcGISDynamicMapServiceLayer.
    
    ' Get the ArcGIS Server version that is serving up the ArcGISDynamicMapServiceLayer.
    Dim myVersion As Double = myArcGISDynamicMapServiceLayer.Version
    
    If myVersion > 10.01 Then
      
      ' No need to do anything! The time-enabled ArcGISDynamicMapServiceLayer will draw all
      ' features even though no Map.TimeExtent has been specified.
      
    Else
      
      ' Since we have an older version of ArcGIS Server, we need to make some adjustments in order to 
      ' show ALL of the features in the time-enabled ArcGISDynamicMapServiceLayer when no Map.TimeExtent
      ' has been specified. Uncomment/Comment out whichever version you want to try (they both produce 
      ' the same results.
      
      ' Option (1):
      ' =====================================================================================
      ' Set the Map.TimeExtent to that of the ArcGISDynamicMapServiceLayer.TimeExtent.
      'Map1.TimeExtent = myTimeExtent 
      
      ' Option (2):
      ' =====================================================================================
      ' Create a new LayerTimeOptionCollection.
      Dim myLayerTimeOptionCollection As New ESRI.ArcGIS.Client.LayerTimeOptionCollection
      
      ' Loop through each LayerInfo object.
      For Each myLayerInfo As ESRI.ArcGIS.Client.LayerInfo In myLayerInfos
        
        ' Create a new TimeOption object and set the LayerID and UseTime Properties. Then add the
        ' TimeOption to the LayerTimeOptionCollection.
        Dim myTimeOption As New ESRI.ArcGIS.Client.Tasks.TimeOption
        myTimeOption.LayerId = CStr(myLayerInfo.ID)
        myTimeOption.UseTime = False
        myLayerTimeOptionCollection.Add(myTimeOption)
      Next
      
      ' Set the ArcGISDynamicMapServiceLayer.LayerTimeOptions to the new custom LayerTimeOptionsCollection.
      myArcGISDynamicMapServiceLayer.LayerTimeOptions = myLayerTimeOptionCollection
      
    End If
    
  Else
    
    'We do not have a time-enabled ArcGISDynamicMapServiceLayer. There is nothing to change.
    
  End If
  
End Sub

Requirements

Target Platforms:Windows Phone 7

See Also

© ESRI, Inc. All Rights Reserved.