Printing map with graphics (SpatialQueryFilter results of FeatureLayer) with the PrintTask

03-31-2015 10:50 AM
New Contributor III

Seems like this should be simple... but I can not find any code samples or documentation on how to print the map that includes the selected items?  The PrintParameters class does not contain a property for "OperationalLayers"?

Do I need to generate my own "Web_Map_as_JSON" string and loop through my graphics to populate the "operationaLayers" with the geometry "rings" from the selection?



Here is my code if it helps...

My map contains a FeatureLayer:

                <esri:FeatureLayer x:Name="DC" ID="DC" MaxScale="500" MinScale="10000" Renderer="{StaticResource mySimpleRenderer2}" >
                        <esri:LabelProperties IsEnabled="True">
                            <esri:AttributeLabelClass MinScale="2500" TextExpression="[TAXLOT]" LabelPlacement="PolygonAlwaysHorizontal" LabelPosition="RepositionOrRemove"  LabelPriority="Highest">
                                <esri:TextSymbol Color="Gray">
                                    <esri:SymbolFont FontFamily="Arial"  FontSize="9" FontWeight="Bold"/>
                    <esri:ServiceFeatureTable Mode="Snapshot" OutFields="*" 

And I'm selecting some items:

        private async void AddSelectButton_Click(object sender, System.Windows.RoutedEventArgs e)
                var features = await FindIntersectingFeaturesAsync();
                var featureIds = features.Select(f => Convert.ToInt64(f.Attributes[DC.FeatureTable.ObjectIDField])).ToArray();
            catch (Exception ex)
                MessageBox.Show("Please click on the map to make a selection", "Selection Error");

        private async Task<IEnumerable<Feature>> FindIntersectingFeaturesAsync()
            var rect = await MapView1.Editor.RequestShapeAsync(DrawShape.Polyline);
            SpatialQueryFilter filter = new SpatialQueryFilter();
            filter.Geometry = GeometryEngine.Project(rect, DC.FeatureTable.SpatialReference);
            filter.SpatialRelationship = SpatialRelationship.Intersects;
            filter.MaximumRows = 1000;
            var features = await DC.FeatureTable.QueryAsync(filter);
            return features;

Finally trying to print:

        private async void printMap()
 var printTask = new PrintTask(new Uri(""));

            PrintParameters printParameters = new PrintParameters(MapView1)
                ExportOptions = new ExportOptions() { Dpi = 96, OutputSize = new Size(MapView1.ActualWidth, MapView1.ActualHeight) },
                LayoutTemplate = "Letter ANSI A Portrait",
                Format = "pdf",

            var result = await printTask.PrintAsync(printParameters);
0 Kudos
0 Replies