ArcGIS Runtime SDK for WPF - Library Reference
TimeOffset Property
See Also  Example
ESRI.ArcGIS.Client.Tasks Namespace > TimeOption Class : TimeOffset Property

Gets or sets the amount of time offset for sub-layer of a time-enabkled ArcGISDynamicMapServiceLayer so that it can be overlaid on the top of a previous or future time period.

Syntax

Visual Basic (Declaration) 
Public Property TimeOffset As Double
C# 
public double TimeOffset {get; set;}

Remarks

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.

The TimeOption.TimeOffset is an optional Property. If this Property is not set, then the effect of the Offset on the temporal data in the sub-layer is zero (0).

Example

How to use:

When the application loads two layers that are based upon the same hurricane track data will be displayed. The hurricane tracks contain data from the year 1851 to the year 2007. Each of the two layers are restricted to only displaying Category 5 hurricanes. One of the hurricane layers is a FeatureLayer and will display the data using Solid Green Polylines. The other layer is an ArcGISDynamicMapServiceLayer and will display the data using Dark Red Solid Green Polylines. A TimeExtent of Jan. 1, 2005 to Dec. 31, 2005 has been applied to the Map Control which further restricts the display of the hurricane data to that window of time. What is unique to this sample is that ArcGISDynamicMapServiceLayer has a TimeOption.TimeOffset of 365 days is applied to the via the ArcGISDynamicMapServiceLayer.LayerTimeOptions resulting in the data that is actually returned being from Jan. 1, 2006 to Dec. 31, 2006!

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 how the TimeOption.TimeOffset can be used in the ArcGISDynamicMapServiceLayer.LayerTimeOptions.

XAMLCopy Code
<Grid x:Name="LayoutRoot">
            
  <!-- 
  Add a Map Control zoomed into the Caribbean region. A TimeExtent is specified to limit the data
  that is displayed in the FeatureLayer and ArcGISDynamicMapServiceLayer between Jan. 1, 2005 and
  Dec. 31, 2005.
  -->
  <esri:Map x:Name="Map1" WrapAround="True" HorizontalAlignment="Left" VerticalAlignment="Top"
            Margin="12,188,0,0" Height="400" Width="400" Extent="-11023120,528979,-7245336,4051956"  
            TimeExtent="2005/01/01 00:00:00 UTC,2005/12/31 00:00:00 UTC" >
  
    <!-- Add an backdrop ArcGISTiledMapServiceLayer. -->
    <esri:ArcGISTiledMapServiceLayer ID="BaseLayer"
                  Url="http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer" />
    
    <!-- 
    Add a FeatureLayer where only Category 5 hurricanes will be displayed. The dataset dates from the year 1851 
    to the year 2007. Because the Map.TimeExtent is set, only hurricanes that fall between Jan. 1, 2005 and
    Dec. 31, 2005 will be displayed (Solid Green Polylines). 
    -->
    <esri:FeatureLayer ID="HurricaneLayer1" Where="CAT = 'H5'"
         Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Hurricanes/NOAA_Tracks_1851_2007/MapServer/0">
      <esri:FeatureLayer.Renderer>
        <esri:SimpleRenderer>
          <esri:SimpleLineSymbol Color="Green" Style="Solid" Width="3"/>
        </esri:SimpleRenderer>
      </esri:FeatureLayer.Renderer>
    </esri:FeatureLayer>
    
    <!--
    Add an ArcGISDynamicMapServiceLayer to the Map. The Initialized event is wired up where in the code-behind
    the data that will be displayed will limit features to only Category 5 hurricanes. Because the Map.TimeExtent 
    is set, only hurricanes that fall between Jan. 1, 2005 and Dec. 31, 2005 are supposed to be displayed (Solid 
    Dark Red Polylines) BUT because a TimeOption.TimeOffset of 365 days is applied to the 
    ArcGISDynamicMapServiceLayer.LayerTimeOptions the data that is actually returned is from Jan. 1, 2006 to Dec.
    31, 2006! 
    -->
    <esri:ArcGISDynamicMapServiceLayer ID="HurricaneLayer2" Initialized="ArcGISDynamicMapServiceLayer_Initialized"
          Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Hurricanes/NOAA_Tracks_1851_2007/MapServer">
    </esri:ArcGISDynamicMapServiceLayer>
    
  </esri:Map>
    
  <!-- Add a Legend Control to demonstrate which features belong to which layers. -->
  <esri:Legend x:Name="MyLegend" Margin="418,188,182,12" Map="{Binding ElementName=Map1}" ShowOnlyVisibleLayers="True"
               Height="400" Width="200" VerticalAlignment="Top" HorizontalAlignment="Left"/>
  
  <!-- Provide the instructions on how to use the sample code. -->
  <TextBlock Height="170" Name="TextBlock1" VerticalAlignment="Top" TextWrapping="Wrap" Margin="12,12,90,0" 
         Text="When the application loads two layers that are based upon the same hurricane track data will be displayed.
         The hurricane tracks contain data from the year 1851 to the year 2007. Each of the two layers are restricted to
         only displaying Category 5 hurricanes. One of the hurricane layers is a FeatureLayer and will display the data 
         using Solid Green Polylines. The other layer is an ArcGISDynamicMapServiceLayer and will display the data using
         Dark Red Solid Green Polylines. A TimeExtent of Jan. 1, 2005 to Dec. 31, 2005 has been applied to the Map Control
         which further restricts the display of the hurricane data to that window of time. What is unique to this sample
         is that ArcGISDynamicMapServiceLayer has a TimeOption.TimeOffset of 365 days is applied to the via the 
         ArcGISDynamicMapServiceLayer.LayerTimeOptions resulting in the data that is actually returned being from Jan. 1, 
         2006 to Dec. 31, 2006!" />
  
</Grid>
C#Copy Code
private void ArcGISDynamicMapServiceLayer_Initialized(object sender, System.EventArgs e)
{
  // Get the ArcGISDynamicMapServiceLayer. 
  ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)sender;
  
  // Create and apply a LayerDefinition which restricts the data being returned on only Category 5 storms.
  ESRI.ArcGIS.Client.LayerDefinition myLayerDefinition = new ESRI.ArcGIS.Client.LayerDefinition();
  myLayerDefinition.Definition = "CAT = 'H5'";
  myLayerDefinition.LayerID = 0;
  myArcGISDynamicMapServiceLayer.LayerDefinitions.Add(myLayerDefinition);
  
  // Create a TimeOption to offset the hurricane data returned by the REST service by 365 days (i.e. 1 year).
  ESRI.ArcGIS.Client.Tasks.TimeOption myTimeOption = new ESRI.ArcGIS.Client.Tasks.TimeOption();
  myTimeOption.LayerId = "0";
  myTimeOption.TimeOffset = 365;
  myTimeOption.TimeOffsetUnit = ESRI.ArcGIS.Client.Tasks.TimeOffsetUnits.Days;
  myTimeOption.UseTime = true;
  
  // Create a new LayerTimeOptionCollection and add the custom TimeOption to it. Then set the 
  // ArcGISDynamicMapServiceLayer.LayerTimeOptionsCollection Property to the new LayerTimeOptionCollection.
  ESRI.ArcGIS.Client.LayerTimeOptionCollection myLayerTimeOptions = new ESRI.ArcGIS.Client.LayerTimeOptionCollection();
  myLayerTimeOptions.Add(myTimeOption);
  myArcGISDynamicMapServiceLayer.LayerTimeOptions = myLayerTimeOptions;
}
VB.NETCopy Code
Private Sub ArcGISDynamicMapServiceLayer_Initialized(sender As System.Object, e As System.EventArgs)
  
  ' Get the ArcGISDynamicMapServiceLayer. 
  Dim myArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer = CType(sender, ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)
            
  ' Create and apply a LayerDefinition which restricts the data being returned on only Category 5 storms.
  Dim myLayerDefinition As New ESRI.ArcGIS.Client.LayerDefinition
  myLayerDefinition.Definition = "CAT = 'H5'"
  myLayerDefinition.LayerID = 0
  myArcGISDynamicMapServiceLayer.LayerDefinitions.Add(myLayerDefinition)
            
  ' Create a TimeOption to offset the hurricane data returned by the REST service by 365 days (i.e. 1 year).
  Dim myTimeOption As New ESRI.ArcGIS.Client.Tasks.TimeOption
  myTimeOption.LayerId = "0"
  myTimeOption.TimeOffset = 365
  myTimeOption.TimeOffsetUnit = ESRI.ArcGIS.Client.Tasks.TimeOffsetUnits.Days
  myTimeOption.UseTime = True
            
  ' Create a new LayerTimeOptionCollection and add the custom TimeOption to it. Then set the 
  ' ArcGISDynamicMapServiceLayer.LayerTimeOptionsCollection Property to the new LayerTimeOptionCollection.
  Dim myLayerTimeOptions As New ESRI.ArcGIS.Client.LayerTimeOptionCollection
  myLayerTimeOptions.Add(myTimeOption)
  myArcGISDynamicMapServiceLayer.LayerTimeOptions = myLayerTimeOptions
            
End Sub

Requirements

Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8

See Also

© ESRI, Inc. All Rights Reserved.