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()));
Solved! Go to Solution.
Overlay graphics that are only adding graphics to the MapView. Overlay graphics is meant to help with Interactive MapView feedback. Like Chris said above you have to use a graphics layer instead.
I used this community sample code in the past for copy/paste inheritance: arcgis-pro-sdk-community-samples/Map-Authoring/GraphicsLayers at master · Esri/arcgis-pro-sdk-commun...
If you download the 'Practical Dockpane' / '2021 Palm Springs' Dev Summit slides and sample code (Tech Sessions · Esri/arcgis-pro-sdk Wiki (github.com)) you can also look the 'CompReporter' sample that is included. The code creates a graphics layer on the fly and uses it in a layout view (and export).
Overlay graphics are not included in image exports in ArcGIS Pro. I know, because I ran into the exact same issue. This has been conformed by ESRI.
It is unclear if this will be added in the future. The alternative is to use the graphics layer instead.
Kris
Overlay graphics that are only adding graphics to the MapView. Overlay graphics is meant to help with Interactive MapView feedback. Like Chris said above you have to use a graphics layer instead.
I used this community sample code in the past for copy/paste inheritance: arcgis-pro-sdk-community-samples/Map-Authoring/GraphicsLayers at master · Esri/arcgis-pro-sdk-commun...
If you download the 'Practical Dockpane' / '2021 Palm Springs' Dev Summit slides and sample code (Tech Sessions · Esri/arcgis-pro-sdk Wiki (github.com)) you can also look the 'CompReporter' sample that is included. The code creates a graphics layer on the fly and uses it in a layout view (and export).