Visual Basic (Declaration) | |
---|---|
Public NotInheritable Class DynamicLayerInfoCollection Inherits System.Collections.ObjectModel.ObservableCollection(Of DynamicLayerInfo) |
C# | |
---|---|
public sealed class DynamicLayerInfoCollection : System.Collections.ObjectModel.ObservableCollection<DynamicLayerInfo> |
Dynamic Layers allow the execution of various ArcGIS Server requests from a client application. An in-depth discussion about Dynamic Layers is in the ArcGISDynamicMapServiceLayer Class documentation. The client side requests that can be issued to ArcGIS Server include the ability to:
- Change the rendering of an existing ArcGISDynamicMapServiceLayer. See the code examples in this document, the ArcGISDynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos Method, and the LayerDrawingOptionsCollection Class.
- Create a layer on-the-fly for the Workspace Types of: Database, Shapefile, FileGDB, and Raster. See the codes example in the ArcGISDynamicMapServiceLayer.DynamicLayerInfos Property document and this document.
- Perform table joins.
- Query for specific records. See the code example for the QueryDataSource Class.
- Identify features. See the code example for the Tasks.IdentifyParameters.DynamicLayerInfos Property.
- Return raster images.
Dynamic Layers are new in ArcGIS Server v10.1 and require the ArcGIS Runtime SDK 1.0 for WPF and higher.
The key to creating a Dynamic Layer is to set the DynamicLayerInfo.Source Property to the appropriate LayerSource object. The LayerSource is an Abstract Class and has two inherited Classes that should be used in setting the DynamicLayerInfo.Source, they are: LayerDataSource and LayerMapSource (review the 'LayerSource Digression' topic section in the ArcGISDynamicMapServiceLayer Class documentation for a more in-depth discussion). One DynamicLayerInfo object is used per Dynamic Layer and is added to a DynamicLayerInfoCollection which is set to the ArcGISDynamicMapServiceLayer.DynamicLayerInfos Property. By default, an ArcGISDynamicMapServiceLayer that was created in ArcMap and served up via ArcGIS Server has its DynamicLayerInfos collection being empty (meaning Nothing/null). Developers can use the ArcGISDynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos Method to populate the DynamicLayerInfoCollection to serve as a starting point for creating a Dynamic Layer or they can create individual DynamicLayerInfo objects from scratch and add them to the DynamicLayerInfoCollection.
The collection of DynamicLayerInfo objects is used to change the Layer ordering or to redefine the Dynamic Layers drawn in the Map. The order of the objects in the DynamicLayerInfoCollection defines the Layer drawing order; specifically the first element of the collection draws on top of all other Layers.
How to use:
Choose a desired Renderer and click the Button to create a Dynamic Layer on-the-fly using code-behind. You can repeat this process for each Renderer to see the different effect. Examples of the 'WorkspaceID' and 'DataSourceName' are provided as comments in the code-behind for a public ArcGIS Server that has Dynamic Layers enabled via the LayerDataSource object.
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. Set the Extent to the Continental United States. --> <esri:Map Background="White" HorizontalAlignment="Left" Margin="0,204,0,0" Name="Map1" VerticalAlignment="Top" Height="350" Width="500" Extent="-129.72,10.47,-62.22,57.72"> <!-- Add a backdrop ArcGISTiledMapServiceLayer. The SpatialReference is 4326 (lat/long). --> <esri:ArcGISTiledMapServiceLayer ID="myArcGISTiledMapServiceLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" /> </esri:Map> <!-- Button to add a Dynamic Layer (using a TableDataSource Tyoe of LayerDataSource) via code-behind. Users choose a different RadioButton to see the Rendering effect on the Dynamic Layer. --> <RadioButton Content="SimpleRenderer" Height="16" HorizontalAlignment="Left" Margin="12,153,0,0" Name="RadioButton_SimpleRenderer" VerticalAlignment="Top" IsChecked="True"/> <RadioButton Content="ClassBreaksRenderer" Height="16" HorizontalAlignment="Left" Margin="160,153,0,0" Name="RadioButton_ClassBreaksRenderer" VerticalAlignment="Top" /> <RadioButton Content="UniqueValueRenderer" Height="16" HorizontalAlignment="Left" Margin="330,153,0,0" Name="RadioButton_UniqueValueRenderer" VerticalAlignment="Top" /> <Button Content="Add a LayerDataSource based Dynamic Layer using the specified Renderer" Height="23" HorizontalAlignment="Left" Margin="0,175,0,0" Name="Button1" VerticalAlignment="Top" Width="500" Click="Button1_Click"/> <!-- Provide the instructions on how to use the sample code. --> <TextBlock Height="147" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="788" TextWrapping="Wrap" Text="Choose a desired Renderer and click the Button to create a Dynamic Layer on-the-fly using code-behind. You can repeat this process for each Renderer to see the different effect. Examples of the 'WorkspaceID' and 'DataSourceName' are provided as comments in the code-behind for a public ArcGIS Server that has Dynamic Layers enabled via the LayerDataSource object."/> </Grid> |
C# | Copy Code |
---|---|
private void Button1_Click(object sender, System.Windows.RoutedEventArgs e) { // Add a Layer on-the-fly based on an ArcGISDynamicMapServiceLayer that has Dynamic Layer capabalities enabled. // The Layer being added DOES NOT come from an existing sub-layer in a LayerMapSource. Rather the Dynamic Layer // is being generated uses the 'Workspace Type' of 'Database' via the LayerDataSource object. Review the // ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer Class documentation in the API reference for a full discussion. // In order to create this Dynamic Layer, information was shared between the Manager/Admininstrator of the // ArcGISDynamicMapServiceLayer ArcGIS Server service and the application developer. // // The Url for the ArcGISDynamicMapServiceLayer is: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer". // // The WorkspaceID used in the LayerDataSource for the Dynamic Layer is: "MyDatabaseWorkspaceIDSSR2" // // There are several DataSourceName types associated with the WorkspaceID that could be used to create the Rendering // of a Dynamic Layer. Think of the DataSourceName as the string name of the layer that will be drawn dynamically. // A listing of the available DataSourceNames (and their geometry type) are: // "ss6.gdb.highways" <== Polylines // "ss6.gdb.states" <== Polygons // "ss6.gdb.counties" <== Polygons // "ss6.gdb.cities" <== Points // "ss6.gdb.lakes" <== Polygons // Create a new TableDataSource object and set it's .WorkspaceID and .DataSourceName Properties to valid values. ESRI.ArcGIS.Client.TableDataSource myTableDataSource = new ESRI.ArcGIS.Client.TableDataSource(); myTableDataSource.WorkspaceID = "MyDatabaseWorkspaceIDSSR2"; myTableDataSource.DataSourceName = "ss6.gdb.states"; // Create a new LayerDataSource and set its DataSource Property to the TableDataSource. ESRI.ArcGIS.Client.LayerDataSource myLayerDataSource = new ESRI.ArcGIS.Client.LayerDataSource(); myLayerDataSource.DataSource = myTableDataSource; // Create a new DynamicLayerInfo object and set its ID and Source Properties. ESRI.ArcGIS.Client.DynamicLayerInfo myDynamicLayerInfo = new ESRI.ArcGIS.Client.DynamicLayerInfo(); myDynamicLayerInfo.ID = 99; // Must be the same as the LayerDrawingOptions.LayerID myDynamicLayerInfo.Source = myLayerDataSource; // Create a new DynamicLayerInfoCollection and add the DynamicLayerInfo object into it. ESRI.ArcGIS.Client.DynamicLayerInfoCollection myDynamicLayerInfoCollection = new ESRI.ArcGIS.Client.DynamicLayerInfoCollection(); myDynamicLayerInfoCollection.Add(myDynamicLayerInfo); // Create a new LayerDrawingOptions object which is key to applying our custom Rendering of the Dynamic Layer. // It is imperative that the LayerDrawingOptions.LayerID = DynamicLayerInfo.ID so that the Dynamic Layer draws // using the new symbology. ESRI.ArcGIS.Client.LayerDrawingOptions myLayerDrawingOptions = new ESRI.ArcGIS.Client.LayerDrawingOptions(); myLayerDrawingOptions.LayerID = 99; // Must be the same as the DynammicLayerInfo.ID // Set the Renderer of the Dynamic Layer based upon the user choice from the RadioButtons in the GUI. if (RadioButton_SimpleRenderer.IsChecked == true) { // Use a SimpleRenderer. myLayerDrawingOptions.Renderer = MakeSimpleRendererFill(); } else if (RadioButton_ClassBreaksRenderer.IsChecked == true) { // Use a ClassBreaksRenderer. Specify the string name of the Field that Rendering will occur on. myLayerDrawingOptions.Renderer = MakeClassBreaksRenderer_Fill("pop2000"); } else if (RadioButton_UniqueValueRenderer.IsChecked == true) { // Use a UniqueValueRenderer. Specify the string name of the Field that Rendering will occur on. myLayerDrawingOptions.Renderer = MakeUniqueValueRenderer_Fill("sub_region"); } // Create a new LayerDrawinOptionsCollection and add the LayerDraingOptions object into it. ESRI.ArcGIS.Client.LayerDrawingOptionsCollection myLayerDrawingOptionsCollection = new ESRI.ArcGIS.Client.LayerDrawingOptionsCollection(); myLayerDrawingOptionsCollection.Add(myLayerDrawingOptions); // Create a new Dynamic Layer that is based upon on a LayerDataSource of an ArcGISDynamicMapServiceLayer // and apply it's custom rendering. ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = new ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer(); myArcGISDynamicMapServiceLayer.Url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer"; myArcGISDynamicMapServiceLayer.DisableClientCaching = true; myArcGISDynamicMapServiceLayer.DynamicLayerInfos = myDynamicLayerInfoCollection; myArcGISDynamicMapServiceLayer.LayerDrawingOptions = myLayerDrawingOptionsCollection; // Add the Dynamic Layer to the Map Control. This causes the round trip server request to occur. Map1.Layers.Add(myArcGISDynamicMapServiceLayer); } public ESRI.ArcGIS.Client.SimpleRenderer MakeSimpleRendererFill() { // Create a SimpleMarkerSymbol and sets it Style to a circle, Color to Red, and Size to 10 points. ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol(); mySimpleFillSymbol.Fill = new System.Windows.Media.SolidColorBrush(Colors.Red); mySimpleFillSymbol.BorderThickness = 1; mySimpleFillSymbol.BorderBrush = new System.Windows.Media.SolidColorBrush(Colors.Black); // Create a new SimpleRenderer based upon the SimpleMarkerSymbol. ESRI.ArcGIS.Client.SimpleRenderer mySimpleRenderer = new ESRI.ArcGIS.Client.SimpleRenderer(); mySimpleRenderer.Symbol = mySimpleFillSymbol; return mySimpleRenderer; } public ESRI.ArcGIS.Client.ClassBreaksRenderer MakeClassBreaksRenderer_Fill(string theFieldName) { // Create a ClassBreaksRenderer using what is specified for theFieldName as the Field to // perform the Rendering. In our case the various ClassBreakInfo objects have hard-coded // .MinimumValue and .MaximumValue settings that are appropriate for the .Field. If you // use a different DataSourceName you will need to adjust these values accordingly. ESRI.ArcGIS.Client.ClassBreaksRenderer myClassBreaksRenderer = new ESRI.ArcGIS.Client.ClassBreaksRenderer(); myClassBreaksRenderer.Field = theFieldName; // Requires a numeric Field // Group #1 ESRI.ArcGIS.Client.ClassBreakInfo myClassBreakInfo1 = new ESRI.ArcGIS.Client.ClassBreakInfo(); myClassBreakInfo1.MinimumValue = 0; myClassBreakInfo1.MaximumValue = 1000000; ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol1 = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol(); System.Windows.Media.SolidColorBrush myBrush1 = new System.Windows.Media.SolidColorBrush(Color.FromArgb(255, 255, 255, 0)); //Yellow mySimpleFillSymbol1.Fill = myBrush1; myClassBreakInfo1.Symbol = mySimpleFillSymbol1; myClassBreaksRenderer.Classes.Add(myClassBreakInfo1); // Group #2 ESRI.ArcGIS.Client.ClassBreakInfo myClassBreakInfo2 = new ESRI.ArcGIS.Client.ClassBreakInfo(); myClassBreakInfo2.MinimumValue = 1000001; myClassBreakInfo2.MaximumValue = 10000000; ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol2 = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol(); System.Windows.Media.SolidColorBrush myBrush2 = new System.Windows.Media.SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); // Black mySimpleFillSymbol2.Fill = myBrush2; myClassBreakInfo2.Symbol = mySimpleFillSymbol2; myClassBreaksRenderer.Classes.Add(myClassBreakInfo2); // Group #3 ESRI.ArcGIS.Client.ClassBreakInfo myClassBreakInfo3 = new ESRI.ArcGIS.Client.ClassBreakInfo(); myClassBreakInfo3.MinimumValue = 10000001; myClassBreakInfo3.MaximumValue = 100000000; ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol3 = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol(); System.Windows.Media.SolidColorBrush myBrush3 = new System.Windows.Media.SolidColorBrush(Color.FromArgb(255, 255, 0, 0)); // Red mySimpleFillSymbol3.Fill = myBrush3; myClassBreakInfo3.Symbol = mySimpleFillSymbol3; myClassBreaksRenderer.Classes.Add(myClassBreakInfo3); return myClassBreaksRenderer; } public ESRI.ArcGIS.Client.UniqueValueRenderer MakeUniqueValueRenderer_Fill(string theFieldName) { // Create a UniqueValueRenderer using what is specified for theFieldName as the Field to // perform the Rendering. In our case the various UniqueValueInfo objects have hard-coded // .Value settings that are appropriate for the .Field. If you use a different // DataSourceName you will need to adjust these values accordingly. ESRI.ArcGIS.Client.UniqueValueRenderer myUniqueValueRenderer = new ESRI.ArcGIS.Client.UniqueValueRenderer(); myUniqueValueRenderer.Field = theFieldName; // Group #1 ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo1 = new ESRI.ArcGIS.Client.UniqueValueInfo(); myUniqueValueInfo1.Value = "Pacific"; ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol1 = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol(); System.Windows.Media.SolidColorBrush myBrush1 = new System.Windows.Media.SolidColorBrush(Colors.Yellow); mySimpleFillSymbol1.Fill = myBrush1; myUniqueValueInfo1.Symbol = mySimpleFillSymbol1; myUniqueValueRenderer.Infos.Add(myUniqueValueInfo1); // Group #2 ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo2 = new ESRI.ArcGIS.Client.UniqueValueInfo(); myUniqueValueInfo2.Value = "W N Cen"; ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol2 = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol(); System.Windows.Media.SolidColorBrush myBrush2 = new System.Windows.Media.SolidColorBrush(Colors.Blue); mySimpleFillSymbol2.Fill = myBrush2; myUniqueValueInfo2.Symbol = mySimpleFillSymbol2; myUniqueValueRenderer.Infos.Add(myUniqueValueInfo2); // Group #3 ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo3 = new ESRI.ArcGIS.Client.UniqueValueInfo(); myUniqueValueInfo3.Value = "W S Cen"; ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol3 = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol(); System.Windows.Media.SolidColorBrush myBrush3 = new System.Windows.Media.SolidColorBrush(Colors.Red); mySimpleFillSymbol3.Fill = myBrush3; myUniqueValueInfo3.Symbol = mySimpleFillSymbol3; myUniqueValueRenderer.Infos.Add(myUniqueValueInfo3); // Group #4 ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo4 = new ESRI.ArcGIS.Client.UniqueValueInfo(); myUniqueValueInfo4.Value = "E N Cen"; ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol4 = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol(); System.Windows.Media.SolidColorBrush myBrush4 = new System.Windows.Media.SolidColorBrush(Colors.White); mySimpleFillSymbol4.Fill = myBrush4; myUniqueValueInfo4.Symbol = mySimpleFillSymbol4; myUniqueValueRenderer.Infos.Add(myUniqueValueInfo4); // Group #5 ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo5 = new ESRI.ArcGIS.Client.UniqueValueInfo(); myUniqueValueInfo5.Value = "Mtn"; ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol5 = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol(); System.Windows.Media.SolidColorBrush myBrush5 = new System.Windows.Media.SolidColorBrush(Colors.Brown); mySimpleFillSymbol5.Fill = myBrush5; myUniqueValueInfo5.Symbol = mySimpleFillSymbol5; myUniqueValueRenderer.Infos.Add(myUniqueValueInfo5); // Group #6 ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo6 = new ESRI.ArcGIS.Client.UniqueValueInfo(); myUniqueValueInfo6.Value = "N Eng"; ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol6 = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol(); System.Windows.Media.SolidColorBrush myBrush6 = new System.Windows.Media.SolidColorBrush(Colors.Cyan); mySimpleFillSymbol6.Fill = myBrush6; myUniqueValueInfo6.Symbol = mySimpleFillSymbol6; myUniqueValueRenderer.Infos.Add(myUniqueValueInfo6); // Group #7 ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo7 = new ESRI.ArcGIS.Client.UniqueValueInfo(); myUniqueValueInfo7.Value = "E S Cen"; ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol7 = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol(); System.Windows.Media.SolidColorBrush myBrush7 = new System.Windows.Media.SolidColorBrush(Colors.Green); mySimpleFillSymbol7.Fill = myBrush7; myUniqueValueInfo7.Symbol = mySimpleFillSymbol7; myUniqueValueRenderer.Infos.Add(myUniqueValueInfo7); // Group #8 ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo8 = new ESRI.ArcGIS.Client.UniqueValueInfo(); myUniqueValueInfo8.Value = "Mid Atl"; ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol8 = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol(); System.Windows.Media.SolidColorBrush myBrush8 = new System.Windows.Media.SolidColorBrush(Colors.Gray); mySimpleFillSymbol8.Fill = myBrush8; myUniqueValueInfo8.Symbol = mySimpleFillSymbol8; myUniqueValueRenderer.Infos.Add(myUniqueValueInfo8); // Group #9 ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo9 = new ESRI.ArcGIS.Client.UniqueValueInfo(); myUniqueValueInfo9.Value = "S Atl"; ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol9 = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol(); System.Windows.Media.SolidColorBrush myBrush9 = new System.Windows.Media.SolidColorBrush(Colors.Orange); mySimpleFillSymbol9.Fill = myBrush9; myUniqueValueInfo9.Symbol = mySimpleFillSymbol9; myUniqueValueRenderer.Infos.Add(myUniqueValueInfo9); return myUniqueValueRenderer; } |
VB.NET | Copy Code |
---|---|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) ' Add a Layer on-the-fly based on an ArcGISDynamicMapServiceLayer that has Dynamic Layer capabalities enabled. ' The Layer being added DOES NOT come from an existing sub-layer in a LayerMapSource. Rather the Dynamic Layer ' is being generated uses the 'Workspace Type' of 'Database' via the LayerDataSource object. Review the ' ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer Class documentation in the API reference for a full discussion. ' In order to create this Dynamic Layer, information was shared between the Manager/Admininstrator of the ' ArcGISDynamicMapServiceLayer ArcGIS Server service and the application developer. ' ' The Url for the ArcGISDynamicMapServiceLayer is: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer". ' ' The WorkspaceID used in the LayerDataSource for the Dynamic Layer is: "MyDatabaseWorkspaceIDSSR2" ' ' There are several DataSourceName types associated with the WorkspaceID that could be used to create the Rendering ' of a Dynamic Layer. Think of the DataSourceName as the string name of the layer that will be drawn dynamically. ' A listing of the available DataSourceNames (and their geometry type) are: ' "ss6.gdb.highways" <== Polylines ' "ss6.gdb.states" <== Polygons ' "ss6.gdb.counties" <== Polygons ' "ss6.gdb.cities" <== Points ' "ss6.gdb.lakes" <== Polygons ' Create a new TableDataSource object and set it's .WorkspaceID and .DataSourceName Properties to valid values. Dim myTableDataSource As New ESRI.ArcGIS.Client.TableDataSource myTableDataSource.WorkspaceID = "MyDatabaseWorkspaceIDSSR2" myTableDataSource.DataSourceName = "ss6.gdb.states" ' Create a new LayerDataSource and set its DataSource Property to the TableDataSource. Dim myLayerDataSource As New ESRI.ArcGIS.Client.LayerDataSource myLayerDataSource.DataSource = myTableDataSource ' Create a new DynamicLayerInfo object and set its ID and Source Properties. Dim myDynamicLayerInfo As New ESRI.ArcGIS.Client.DynamicLayerInfo myDynamicLayerInfo.ID = 99 ' Must be the same as the LayerDrawingOptions.LayerID myDynamicLayerInfo.Source = myLayerDataSource ' Create a new DynamicLayerInfoCollection and add the DynamicLayerInfo object into it. Dim myDynamicLayerInfoCollection As New ESRI.ArcGIS.Client.DynamicLayerInfoCollection myDynamicLayerInfoCollection.Add(myDynamicLayerInfo) ' Create a new LayerDrawingOptions object which is key to applying our custom Rendering of the Dynamic Layer. ' It is imperative that the LayerDrawingOptions.LayerID = DynamicLayerInfo.ID so that the Dynamic Layer draws ' using the new symbology. Dim myLayerDrawingOptions As New ESRI.ArcGIS.Client.LayerDrawingOptions myLayerDrawingOptions.LayerID = 99 ' Must be the same as the DynammicLayerInfo.ID ' Set the Renderer of the Dynamic Layer based upon the user choice from the RadioButtons in the GUI. If RadioButton_SimpleRenderer.IsChecked = True Then ' Use a SimpleRenderer. myLayerDrawingOptions.Renderer = MakeSimpleRendererFill() ElseIf RadioButton_ClassBreaksRenderer.IsChecked = True Then ' Use a ClassBreaksRenderer. Specify the string name of the Field that Rendering will occur on. myLayerDrawingOptions.Renderer = MakeClassBreaksRenderer_Fill("pop2000") ElseIf RadioButton_UniqueValueRenderer.IsChecked = True Then ' Use a UniqueValueRenderer. Specify the string name of the Field that Rendering will occur on. myLayerDrawingOptions.Renderer = MakeUniqueValueRenderer_Fill("sub_region") End If ' Create a new LayerDrawinOptionsCollection and add the LayerDraingOptions object into it. Dim myLayerDrawingOptionsCollection As New ESRI.ArcGIS.Client.LayerDrawingOptionsCollection myLayerDrawingOptionsCollection.Add(myLayerDrawingOptions) ' Create a new Dynamic Layer that is based upon on a LayerDataSource of an ArcGISDynamicMapServiceLayer ' and apply it's custom rendering. Dim myArcGISDynamicMapServiceLayer As New ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer.Url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer" myArcGISDynamicMapServiceLayer.DisableClientCaching = True myArcGISDynamicMapServiceLayer.DynamicLayerInfos = myDynamicLayerInfoCollection myArcGISDynamicMapServiceLayer.LayerDrawingOptions = myLayerDrawingOptionsCollection ' Add the Dynamic Layer to the Map Control. This causes the round trip server request to occur. Map1.Layers.Add(myArcGISDynamicMapServiceLayer) End Sub Public Function MakeSimpleRendererFill() As ESRI.ArcGIS.Client.SimpleRenderer ' Create a SimpleMarkerSymbol and sets it Style to a circle, Color to Red, and Size to 10 points. Dim mySimpleFillSymbol As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol mySimpleFillSymbol.Fill = New System.Windows.Media.SolidColorBrush(Colors.Red) mySimpleFillSymbol.BorderThickness = 1 mySimpleFillSymbol.BorderBrush = New System.Windows.Media.SolidColorBrush(Colors.Black) ' Create a new SimpleRenderer based upon the SimpleMarkerSymbol. Dim mySimpleRenderer As New ESRI.ArcGIS.Client.SimpleRenderer mySimpleRenderer.Symbol = mySimpleFillSymbol Return mySimpleRenderer End Function Public Function MakeClassBreaksRenderer_Fill(ByVal theFieldName As String) As ESRI.ArcGIS.Client.ClassBreaksRenderer ' Create a ClassBreaksRenderer using what is specified for theFieldName as the Field to ' perform the Rendering. In our case the various ClassBreakInfo objects have hard-coded ' .MinimumValue and .MaximumValue settings that are appropriate for the .Field. If you ' use a different DataSourceName you will need to adjust these values accordingly. Dim myClassBreaksRenderer As New ESRI.ArcGIS.Client.ClassBreaksRenderer myClassBreaksRenderer.Field = theFieldName ' Requires a numeric Field ' Group #1 Dim myClassBreakInfo1 As New ESRI.ArcGIS.Client.ClassBreakInfo myClassBreakInfo1.MinimumValue = 0 myClassBreakInfo1.MaximumValue = 1000000 Dim mySimpleFillSymbol1 As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol Dim myBrush1 As New System.Windows.Media.SolidColorBrush(Color.FromArgb(255, 255, 255, 0)) 'Yellow mySimpleFillSymbol1.Fill = myBrush1 myClassBreakInfo1.Symbol = mySimpleFillSymbol1 myClassBreaksRenderer.Classes.Add(myClassBreakInfo1) ' Group #2 Dim myClassBreakInfo2 As New ESRI.ArcGIS.Client.ClassBreakInfo myClassBreakInfo2.MinimumValue = 1000001 myClassBreakInfo2.MaximumValue = 10000000 Dim mySimpleFillSymbol2 As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol Dim myBrush2 As New System.Windows.Media.SolidColorBrush(Color.FromArgb(255, 0, 0, 0)) ' Black mySimpleFillSymbol2.Fill = myBrush2 myClassBreakInfo2.Symbol = mySimpleFillSymbol2 myClassBreaksRenderer.Classes.Add(myClassBreakInfo2) ' Group #3 Dim myClassBreakInfo3 As New ESRI.ArcGIS.Client.ClassBreakInfo myClassBreakInfo3.MinimumValue = 10000001 myClassBreakInfo3.MaximumValue = 100000000 Dim mySimpleFillSymbol3 As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol Dim myBrush3 As New System.Windows.Media.SolidColorBrush(Color.FromArgb(255, 255, 0, 0)) ' Red mySimpleFillSymbol3.Fill = myBrush3 myClassBreakInfo3.Symbol = mySimpleFillSymbol3 myClassBreaksRenderer.Classes.Add(myClassBreakInfo3) Return myClassBreaksRenderer End Function Public Function MakeUniqueValueRenderer_Fill(ByVal theFieldName As String) As ESRI.ArcGIS.Client.UniqueValueRenderer ' Create a UniqueValueRenderer using what is specified for theFieldName as the Field to ' perform the Rendering. In our case the various UniqueValueInfo objects have hard-coded ' .Value settings that are appropriate for the .Field. If you use a different ' DataSourceName you will need to adjust these values accordingly. Dim myUniqueValueRenderer As New ESRI.ArcGIS.Client.UniqueValueRenderer myUniqueValueRenderer.Field = theFieldName ' Group #1 Dim myUniqueValueInfo1 As New ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo1.Value = "Pacific" Dim mySimpleFillSymbol1 As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol Dim myBrush1 As New System.Windows.Media.SolidColorBrush(Colors.Yellow) mySimpleFillSymbol1.Fill = myBrush1 myUniqueValueInfo1.Symbol = mySimpleFillSymbol1 myUniqueValueRenderer.Infos.Add(myUniqueValueInfo1) ' Group #2 Dim myUniqueValueInfo2 As New ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo2.Value = "W N Cen" Dim mySimpleFillSymbol2 As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol Dim myBrush2 As New System.Windows.Media.SolidColorBrush(Colors.Blue) mySimpleFillSymbol2.Fill = myBrush2 myUniqueValueInfo2.Symbol = mySimpleFillSymbol2 myUniqueValueRenderer.Infos.Add(myUniqueValueInfo2) ' Group #3 Dim myUniqueValueInfo3 As New ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo3.Value = "W S Cen" Dim mySimpleFillSymbol3 As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol Dim myBrush3 As New System.Windows.Media.SolidColorBrush(Colors.Red) mySimpleFillSymbol3.Fill = myBrush3 myUniqueValueInfo3.Symbol = mySimpleFillSymbol3 myUniqueValueRenderer.Infos.Add(myUniqueValueInfo3) ' Group #4 Dim myUniqueValueInfo4 As New ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo4.Value = "E N Cen" Dim mySimpleFillSymbol4 As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol Dim myBrush4 As New System.Windows.Media.SolidColorBrush(Colors.White) mySimpleFillSymbol4.Fill = myBrush4 myUniqueValueInfo4.Symbol = mySimpleFillSymbol4 myUniqueValueRenderer.Infos.Add(myUniqueValueInfo4) ' Group #5 Dim myUniqueValueInfo5 As New ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo5.Value = "Mtn" Dim mySimpleFillSymbol5 As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol Dim myBrush5 As New System.Windows.Media.SolidColorBrush(Colors.Brown) mySimpleFillSymbol5.Fill = myBrush5 myUniqueValueInfo5.Symbol = mySimpleFillSymbol5 myUniqueValueRenderer.Infos.Add(myUniqueValueInfo5) ' Group #6 Dim myUniqueValueInfo6 As New ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo6.Value = "N Eng" Dim mySimpleFillSymbol6 As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol Dim myBrush6 As New System.Windows.Media.SolidColorBrush(Colors.Cyan) mySimpleFillSymbol6.Fill = myBrush6 myUniqueValueInfo6.Symbol = mySimpleFillSymbol6 myUniqueValueRenderer.Infos.Add(myUniqueValueInfo6) ' Group #7 Dim myUniqueValueInfo7 As New ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo7.Value = "E S Cen" Dim mySimpleFillSymbol7 As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol Dim myBrush7 As New System.Windows.Media.SolidColorBrush(Colors.Green) mySimpleFillSymbol7.Fill = myBrush7 myUniqueValueInfo7.Symbol = mySimpleFillSymbol7 myUniqueValueRenderer.Infos.Add(myUniqueValueInfo7) ' Group #8 Dim myUniqueValueInfo8 As New ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo8.Value = "Mid Atl" Dim mySimpleFillSymbol8 As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol Dim myBrush8 As New System.Windows.Media.SolidColorBrush(Colors.Gray) mySimpleFillSymbol8.Fill = myBrush8 myUniqueValueInfo8.Symbol = mySimpleFillSymbol8 myUniqueValueRenderer.Infos.Add(myUniqueValueInfo8) ' Group #9 Dim myUniqueValueInfo9 As New ESRI.ArcGIS.Client.UniqueValueInfo myUniqueValueInfo9.Value = "S Atl" Dim mySimpleFillSymbol9 As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol Dim myBrush9 As New System.Windows.Media.SolidColorBrush(Colors.Orange) mySimpleFillSymbol9.Fill = myBrush9 myUniqueValueInfo9.Symbol = mySimpleFillSymbol9 myUniqueValueRenderer.Infos.Add(myUniqueValueInfo9) Return myUniqueValueRenderer End Function |
System.Object
System.Collections.ObjectModel.Collection<T>
System.Collections.ObjectModel.ObservableCollection<T>
ESRI.ArcGIS.Client.DynamicLayerInfoCollection
Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8