FeatureLayer not included in print using PrintParameters(layers, extent) constructor

2536
2
11-11-2013 02:55 PM
Labels (1)
DaveTimmins
Occasional Contributor II
Hi,

I'm trying to get printing working from a viewmodel and when I construct the PrintParameters I'm using the public PrintParameters(IEnumerable<Layer> layers, Envelope mapExtent) constructor as I don't have a reference to the map control. This works for all layers except feature layers. I'm creating the layers from a model class so I'm not cloning the layers. The problem is that it does not get serialized and sent as part of the request to export web map in the operational layers. It looks like its due to the SDK checking if the layer has any graphics (ToJson() method of PrintParameters) which it doesn't since the layer is not initialized though I have set the url, token and where clause. I can see why it doesn't work but in this scenario I would think its valid to still expect the print to include the feature layer and do a server side call to the service rather than trying to send the client state of the layer. This is with the 10.2 release of the SDK. Thoughts?
0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor
Hi,

Thank you for submitting this bug report. As part of optimizing the serialization of layers for printing, GraphicsLayer without Graphics are ignored. But we should include a check that the GraphicsLayer is not a FeatureLayer for this may also mean that the layer is simply not initialized (as in your case).

For the meantime, as a workaround you can add a temporary graphic to a FeatureLayer that is not yet initialized before you execute print.

if(!layer.IsInitialized) // Note that if FeatureLayer is already initialized, this may cause an edit.
   layer.Graphics.Add(new Graphic()); // this graphic will be cleared after FeatureLayer.UpdateCompleted is raised.
mapLayers.Add(layer);


Do the workaround above before executing a print. In code below, t is PrintTask, r is the PrintResult.
 
                var r = await t.ExecuteTaskAsync(new PrintParameters(mapLayers, mapExtent)
                {
                    ExportOptions = new ExportOptions()
                    {
                        OutputSize = new Size(200, 200)
                    }
                });


We'll try to get this fixed in future releases of the API.

Jennifer
0 Kudos
DaveTimmins
Occasional Contributor II
Hi Jennifer,

yea I'd already done that as a workaround but thanks for confirming the bug.
0 Kudos