Visual Basic (Declaration) | |
---|---|
Public NotInheritable Class LayerTimeOptionCollection Inherits System.Collections.Generic.List(Of TimeOption) |
C# | |
---|---|
public sealed class LayerTimeOptionCollection : System.Collections.Generic.List<TimeOption> |
Using the Read/Get of the ArcGISDynamicMapServiceLayer.LayerTimeOptions Property returns null/Nothing unless it has been explicitly set by the developer (it is not automatically set as a 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 ArcGISDynamicMapServiceLayer.LayerTimeOptions Property. An ArcGISDynamicMapServiceLayer can have multiple TimeOption objects; one for each sub-layer in the ArcGISDynamicMapServiceLayer.
The TimeOption object indicates whether or not the sub-layer of an ArcGISDynamicMapSericeLayer should use the TimeExtent specified by the time parameter or not (see TimeOption.UseTime), 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).
How to use:
When the application starts a time-enabled ArcGISDynamicMapServiceLayer with two sub-layers is added to the Map Control. Initially the two sub-layers are restricted to only show features that fall within the Map.TimeExtent of Jan. 1, 1945 to Jan. 1, 1960. Click the various 'Sub-layer X: UseTime' CheckBoxes and click the Button to re-render the ArcGISDynamicMapServiceLayer to see the effect of expanding the Map.TimeExtent for a particular sub-layer to that of the TimeExent of the REST service, which is Jan. 1, 1945 to Jan. 1, 2009.
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 zoomed to Stanton County Kansas. An initial Map.TimeExtent is specified from Jan. 1, 1945 to Jan. 1, 1960 that restricts the 'window-of-time' for which features are displayed in the ArcGISDynamicMapServiceLayer. --> <esri:Map x:Name="Map1" WrapAround="True" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="12,193,0,0" Height="400" Width="400" Extent="-11364678,4479899,-11291472,4553106" TimeExtent="1945/01/01 00:00:00 UTC, 1960/01/01 00:00:00 UTC"> <!-- Add a backdrop ArcGISTiledMapServiceLayer. --> <esri:ArcGISTiledMapServiceLayer ID="BaseLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer" /> <!-- Add the ArcGISDynamicMapServiceLayer that is time-enabled. It has two sub-layers. --> <esri:ArcGISDynamicMapServiceLayer ID="StantonCountyKSLeases" DisableClientCaching="True" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/StantonCountyKSLeases/MapServer"> </esri:ArcGISDynamicMapServiceLayer> </esri:Map> <!-- Add a Legend Control to demonstrate which features belong to which layers. --> <esri:Legend x:Name="MyLegend" Margin="418,193,0,0" Map="{Binding ElementName=Map1}" ShowOnlyVisibleLayers="True" Height="400" Width="300" VerticalAlignment="Top" HorizontalAlignment="Left"/> <!-- Add two CheckBoxes, one for each sub-layer in the ArcGISDynamicMapServiceLayer, that give the user the ability to control the TimeOption.UseTime Property for each sub-layer. Then click the button to call code-behind functions to re-render the Map Control. --> <CheckBox Content="Sub-layer 0: UseTime" HorizontalAlignment="Left" Margin="12,147,0,437" Name="CheckBox_SubLayer0" IsChecked="True"/> <CheckBox Content="Sub-layer 1: UseTime" Height="16" HorizontalAlignment="Left" Margin="12,172,0,0" Name="CheckBox_SubLayer1" VerticalAlignment="Top" IsChecked="True" /> <Button Content="Re-draw the time-enabled ArcGISDynamicMapServiceLayer" Height="41" HorizontalAlignment="Left" Margin="179,147,0,0" Name="Button1" VerticalAlignment="Top" Width="539" Click="Button1_Click"/> <!-- Provide the instructions on how to use the sample code. --> <TextBlock Height="141" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="788" TextWrapping="Wrap" Text="When the application starts a time-enabled ArcGISDynamicMapServiceLayer with two sub-layers is added to the Map Control. Initially the two sub-layers are restricted to only show features that fall within the Map.TimeExtent of Jan. 1, 1945 to Jan. 1, 1960. Click the various 'Sub-layer X: UseTime' CheckBoxes and click the Button to re-render the ArcGISDynamicMapServiceLayer to see the effect of expanding the Map.TimeExtent for a particular sub-layer to that of the TimeExent of the REST service, which is Jan. 1, 1945 to Jan. 1, 2009." /> </Grid> |
C# | Copy Code |
---|---|
private void Button1_Click(object sender, System.Windows.RoutedEventArgs e) { // Get the ArcGISDynamicMapServiceLayer. ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)(Map1.Layers["StantonCountyKSLeases"]); // Create a new LayerTimeOptionCollection. ESRI.ArcGIS.Client.LayerTimeOptionCollection myLayerTimeOptionCollection = new ESRI.ArcGIS.Client.LayerTimeOptionCollection(); // For sub-layer 0, create a new TimeOption and allow the user to specify what TimeOption.UseTime // value they want to set. Then add the TimeOption to the new LayerTimeOptionCollection. ESRI.ArcGIS.Client.Tasks.TimeOption myTimeOption_SubLayer0 = new ESRI.ArcGIS.Client.Tasks.TimeOption(); myTimeOption_SubLayer0.LayerId = "0"; if (CheckBox_SubLayer0.IsChecked == true) { myTimeOption_SubLayer0.UseTime = true; } else if (CheckBox_SubLayer0.IsChecked == false) { myTimeOption_SubLayer0.UseTime = false; } myLayerTimeOptionCollection.Add(myTimeOption_SubLayer0); // For sub-layer 1, create a new TimeOption and allow the user to specify what TimeOption.UseTime // value they want to set. Then add the TimeOption to the new LayerTimeOptionCollection. ESRI.ArcGIS.Client.Tasks.TimeOption myTimeOption_SubLayer1 = new ESRI.ArcGIS.Client.Tasks.TimeOption(); myTimeOption_SubLayer1.LayerId = "1"; if (CheckBox_SubLayer1.IsChecked == true) { myTimeOption_SubLayer1.UseTime = true; } else if (CheckBox_SubLayer1.IsChecked == false) { myTimeOption_SubLayer1.UseTime = false; } myLayerTimeOptionCollection.Add(myTimeOption_SubLayer1); // Set the ArcGISDynamicMapServiceLayer.LayerTimeOptions to the new customized LayerTimeOptionCollection. myArcGISDynamicMapServiceLayer.LayerTimeOptions = myLayerTimeOptionCollection; // Refresh the ArcGISDynamicMapServiceLayer so that it re-renders in the Map Control. myArcGISDynamicMapServiceLayer.Refresh(); } |
VB.NET | Copy Code |
---|---|
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) ' Get the ArcGISDynamicMapServiceLayer. Dim myArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer = CType(Map1.Layers("StantonCountyKSLeases"), ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer) ' Create a new LayerTimeOptionCollection. Dim myLayerTimeOptionCollection As New ESRI.ArcGIS.Client.LayerTimeOptionCollection ' For sub-layer 0, create a new TimeOption and allow the user to specify what TimeOption.UseTime ' value they want to set. Then add the TimeOption to the new LayerTimeOptionCollection. Dim myTimeOption_SubLayer0 As New ESRI.ArcGIS.Client.Tasks.TimeOption myTimeOption_SubLayer0.LayerId = "0" If CheckBox_SubLayer0.IsChecked = True Then myTimeOption_SubLayer0.UseTime = True ElseIf CheckBox_SubLayer0.IsChecked = False Then myTimeOption_SubLayer0.UseTime = False End If myLayerTimeOptionCollection.Add(myTimeOption_SubLayer0) ' For sub-layer 1, create a new TimeOption and allow the user to specify what TimeOption.UseTime ' value they want to set. Then add the TimeOption to the new LayerTimeOptionCollection. Dim myTimeOption_SubLayer1 As New ESRI.ArcGIS.Client.Tasks.TimeOption myTimeOption_SubLayer1.LayerId = "1" If CheckBox_SubLayer1.IsChecked = True Then myTimeOption_SubLayer1.UseTime = True ElseIf CheckBox_SubLayer1.IsChecked = False Then myTimeOption_SubLayer1.UseTime = False End If myLayerTimeOptionCollection.Add(myTimeOption_SubLayer1) ' Set the ArcGISDynamicMapServiceLayer.LayerTimeOptions to the new customized LayerTimeOptionCollection. myArcGISDynamicMapServiceLayer.LayerTimeOptions = myLayerTimeOptionCollection ' Refresh the ArcGISDynamicMapServiceLayer so that it re-renders in the Map Control. myArcGISDynamicMapServiceLayer.Refresh() End Sub |
System.Object
System.Collections.Generic.List<T>
ESRI.ArcGIS.Client.LayerTimeOptionCollection
Target Platforms: Windows Vista, Windows 7