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

3379
0
03-31-2015 10:50 AM
ShadCampbell
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?

Thanks,

Shad

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:FeatureLayer.Labeling>
                        <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:TextSymbol>
                            </esri:AttributeLabelClass>
                        </esri:LabelProperties>
                    </esri:FeatureLayer.Labeling>
                    <esri:ServiceFeatureTable Mode="Snapshot" OutFields="*" 
                ServiceUri="http://XXXX.XXXX.org/arcgis/rest/services/ReferenceMap/MapServer/118"/>
                </esri:FeatureLayer>

And I'm selecting some items:

        private async void AddSelectButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                var features = await FindIntersectingFeaturesAsync();
                var featureIds = features.Select(f => Convert.ToInt64(f.Attributes[DC.FeatureTable.ObjectIDField])).ToArray();
                DC.SelectFeatures(featureIds);
            }
            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("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%2..."));

            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);
            Process.Start(result.Uri.AbsoluteUri);
        }
0 Kudos
0 Replies