Exporting layout after changing extents of its map frames

266
2
06-22-2022 06:00 AM
GISTaldor
New Contributor II

Hi.

I'm trying to export teh active layout inside a loop, which employs some custom business logic in order to change map frame extent.

Here's code template:

mapView.PanTo(extentShape);

mapView.Redraw(true);

LayoutView.Active.Layout.Export(new PDFFormat...);

 

The thing is, that the exported PDF doesn't contain all layers.

It looks like PanTo method isn't blocking until the actual rendering on the view is finished,

so the Export method outputs only what's in the view at at that time.

Am I missing something? Is there some way to determine that the views of all the map frames on the layout finished their redrawing and are ready for export?

 

Thanks

 

 

 

0 Kudos
2 Replies
CharlesMacleod
Esri Regular Contributor

the UI probably needs a chance to redraw between the PanTo and the Export. Try splitting it across two QueuedTask invocations and await the first. You shouldnt need the redraw. So...

await QueuedTask,Run(()=> ....PanTo() ...);

//the UI will refresh here

var layout = LayoutView.Active.Layout;

QueuedTask.Run(() => layout.Export() ....);

 

This is, essentially the same as calling mapView.PanToAsync() with an _await_ which should have the same effect....so:

await mapView.PanToAsync(....);

var layout = LayoutView.Active.Layout;

QueuedTask.Run(() => layout.Export() ....);

 

 

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I think that Charlie has already addressed your issue, however, i just wanted to mention that you could also use a Layout Map Series in order to manipulate map frame extends for your layouts.   Using a Map Series also allows you to apply map series specific properties that allow you to apply labelling specific to each map frame.   There is a community sample available that does something similar:

arcgis-pro-sdk-community-samples/Layouts/LayoutMapSeries at master · Esri/arcgis-pro-sdk-community-s...

 

0 Kudos