Hi,
I have some graphics (using a sketch tool, polyline) that I want to be shown in a PNG image export. I have added these graphics as overlay graphics as they are temporary only.
However when I try to export the PNG - they do not show up in the exported image.
Please help - but I'm guessing I have to use a proper graphics layer and have it added to the TOC - I didn't really want to do this as it is a temporary sketch and adding a graphics layers seem a bit more persisted.
The code below is showing how I create the export image:
public static Task<bool> ExportMapToImage(Geometry geometry, string fileName)
{
return QueuedTask.Run(() =>
{
MapView map = MapView.Active;
string tempPath = GeneralUtils.GetTempPath();
string filePath = System.IO.Path.Combine(tempPath, fileName);
if (File.Exists(filePath))
{
File.Delete(filePath);
}
//Create PNG format with appropriate settings
PNGFormat PNG = new PNGFormat();
PNG.Resolution = 150;
PNG.Height = 500;// geometry.Extent.Height;
PNG.Width = 800;// geometry.Extent.Width;
PNG.OutputFileName = filePath;
//Export active map view
if (PNG.ValidateOutputFilePath())
{
map.Export(PNG);
}
return true;
});
}
This code shows how I am adding the graphics to the overlay:
_graphicList.Add(mapView.AddOverlay(polyline, SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.CreateRGBColor(0, 0, 0), 2, SimpleLineStyle.Solid).MakeSymbolReference()));