private void ExportMap_Click(object sender, RoutedEventArgs e) { if (printTask == null || printTask.IsBusy) return; // Define the LegendOptions. This will show specified Layers in the printed map's legend area. LegendOptions myLegendOptions = new LegendOptions(); // Define a List<LegendLayer> objects to put in the LegendOptions. List<LegendLayer> myLegendLayers = new List<LegendLayer>(); // Loop through all of the Layers in the Map Control. foreach (var myLayer in MyMap.Layers) { // Create a new LegendLayer object to put in the List<LegendLayer> collection. LegendLayer myLegendLayer = new LegendLayer(); // Set the LegendLayer.LayerId to the Layer.ID to add it to the printed map's legend area. myLegendLayer.LayerId = myLayer.ID; if (myLayer.ID == "Water Rights" || myLayer.ID == "OWRD Layers") { // Add a single LegendLayer into the List<LegendLayer> collection. myLegendLayers.Add(myLegendLayer); } } // Set the LegendOptions.LegendLayer to the new constructed List<LegendLayer> objects. myLegendOptions.LegendLayers = myLegendLayers; PrintParameters printParameters = new PrintParameters(MyMap) { LayoutOptions = new LayoutOptions() { Title=MapTitle.Text, Copyright = "Map generated by Or Water Resources Department", LegendOptions = myLegendOptions}, ExportOptions = new ExportOptions() { Dpi = 96, OutputSize = new Size(MyMap.ActualWidth, MyMap.ActualHeight) }, LayoutTemplate = (string)LayoutTemplates.SelectedItem ?? string.Empty, Format = (string)Formats.SelectedItem, }; printTask.ExecuteAsync(printParameters); }
<esri:Legend x:Name="Legend" Map="{Binding ElementName=MyMap}" LayerIDs="Labels, Public Schools, Non-Public Schools, Attendance Areas" LayerItemsMode="Flat" ShowOnlyVisibleLayers="False" Refreshed="Legend_Refreshed" />
private void Legend_Refreshed(object sender, Legend.RefreshedEventArgs e) { LayerItemViewModel removeLayerItemVM = null; if (e.LayerItem.Layer is ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer) e.LayerItem.LayerItems = null; if (e.LayerItem.LayerItems != null) { foreach (LayerItemViewModel layerItemVM in e.LayerItem.LayerItems) { if (layerItemVM.IsExpanded) layerItemVM.IsExpanded = false; } if (removeLayerItemVM != null) e.LayerItem.LayerItems.Remove(removeLayerItemVM); } else { e.LayerItem.IsExpanded = true; } }
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.