I solved it, almost... In the ExportMap_Click, I turn off the secured layer before I print. This does not help, tho, should we want to actually print the features on the secured layer.
if (myLayer.ID == "Tax Lots" )
{
myLayer.Visible = false;
}
But your suggestion of using the full url for the proxy helped with another issue I had - I wasn't able to test the application right from Visual Studio with the relative pathname. With the full pathname, I can. Yeah! 😄For the full code of the ExportMap_Click...
private void ExportMap_Click(object sender, RoutedEventArgs e)
{
if (printTask == null || printTask.IsBusy) return;
busyIndicator.Visibility = Visibility.Visible;
// 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);
}
if (myLayer.ID == "Tax Lots" )
{
myLayer.Visible = false;
}
}
// 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,
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);
}