What I am trying to do is import a .pagx map template and use my active map (Layers) for the MapFrame in my template.
I am able to import my .pagx map template. When it is imported, a new Map is created (Layers1) which from the map template layout. I have tried setting the MapFrame's .Map property but this is readonly.
It might not be the correct way to do this, but I was hoping I could set this property to my active map.
var mv = MapView.Active;
var currentCamera = mv?.Camera;
QueuedTask.Run(() =>
{
IProjectMultiItem pagx = ItemFactory.Instance.Create(TemplatePath) as IProjectMultiItem;
Project.Current.ImportItem(pagx);
LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().Last();
// Get the layout from the layout template item
Layout layout = layoutItem.GetLayout();
if (mapFrame != null)
{
// Get map frame
var mapFrameMap = mapFrame.Map;
// Setting the mapFrameMap var does not make a change
//mapFrameMap = mv.Map;
mapFrame.Map = mv.Map;
if (currentCamera != null)
mapFrame.SetCamera(currentCamera);
}
});