private void AddLayerButton_Click(object sender, RoutedEventArgs e) { var layerInfos = this.dynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos(); int highestId = -1; if (layerInfos.Count != 0) { highestId = layerInfos.Max(x => x.ID); } var newInfo = new DynamicLayerInfo() { ID = highestId + 1, Source = new LayerDataSource() { DataSource = new TableDataSource() { DataSourceName = "parkboundary", WorkspaceID = "DemoGDB" } }, }; layerInfos.Add(newInfo); this.dynamicMapServiceLayer.DynamicLayerInfos = layerInfos; LayerDrawingOptions layerDrawOpt = new LayerDrawingOptions(); layerDrawOpt.LayerID = highestId + 1; layerDrawOpt.Renderer = new SimpleRenderer() { Symbol = GetSimpleFillSymbol(Colors.Blue, Colors.Blue, 1) }; this.dynamicMapServiceLayer.LayerDrawingOptions = new LayerDrawingOptionsCollection() { layerDrawOpt }; this.dynamicMapServiceLayer.Refresh(); }
<Window x:Class="DynamicLayersDemo.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:esri="http://schemas.esri.com/arcgis/client/2009" Title="ArcGIS Runtime SDK for WPF" Height="350" Width="525" WindowState="Maximized"> <Grid> <esri:Map x:Name="MapControl" Background="LightGray"> </esri:Map> <Grid HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,15,15,0" > <Rectangle Fill="#77919191" Stroke="Gray" RadiusX="10" RadiusY="10" Margin="0,0,0,5" > <Rectangle.Effect> <DropShadowEffect/> </Rectangle.Effect> </Rectangle> <Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" /> <StackPanel Orientation="Vertical" Margin="20,20,20,20" HorizontalAlignment="Left" > <TextBlock Text="Dynamic Layers Demo" HorizontalAlignment="Center" FontWeight="Bold" Margin="5,0,5,5" FontSize="18"/> <TextBlock x:Name="InformationTextBlock" Text="Choose a new feature class and color ramp from the list below:" Width="200" TextAlignment="Left" TextWrapping="Wrap" Margin="5,0,5,5" FontSize="16"/> <ComboBox x:Name="NutsLevelsComboBox" SelectedIndex="0" Margin="5,0,5,5" FontSize="16"> <ComboBoxItem>NUTS0 (country level)</ComboBoxItem> <ComboBoxItem>NUTS1 (3-7m people)</ComboBoxItem> <ComboBoxItem>NUTS2 (0.8-3m people)</ComboBoxItem> <ComboBoxItem>NUTS3 (0.15-0.8m people)</ComboBoxItem> </ComboBox> <ComboBox x:Name="colorComboBox" SelectedIndex="0" Margin="5,0,5,5" FontSize="16"> <ComboBoxItem>Yellow to Red</ComboBoxItem> <ComboBoxItem>Green to Blue</ComboBoxItem> </ComboBox> <Button x:Name="UpdateMapButton" Click="UpdateMapButton_Click" Margin="5,0,5,5" FontSize="16">Update Map</Button> </StackPanel> </Grid> </Grid> </Window>
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.