Hi Guys,
I am currently trying to find a way of adding mapx into project silently instead of loading the map pane.
Because the tool I create require to be active at current layout, after the mapx is added, it is switched back to map pane.
Any way I can achieve without switching to map pane?
Any idea Uma Harano, Wolfgang Kaiser?
Below is the code I use at the moment. Pro version is 2.5
IProjectItem mapX = ItemFactory.Instance.Create("///mapx file path") as IProjectItem;
bool isAdd = Project.Current.AddItem(mapX);
//After Queuetask await is done, the current active layout pane switch to newly added map pane
Solved! Go to Solution.
You can find the information you're looking for here: ProConcepts Content and Items · Esri/arcgis-pro-sdk Wiki · GitHub
In code it would look like this (needless to say you can drop the pmi==null check in your code):
IProjectItem mapX = ItemFactory.Instance.Create(@"c:\temp\TheMap.mapx") as IProjectItem;
IProjectMultiItem pmi = mapX as IProjectMultiItem;
if (pmi == null) MessageBox.Show("Does not implement IProjectMultiItem");
else Project.Current.ImportItem(pmi, false);
Any idea ArcGIS Pro SDK
You can find the information you're looking for here: ProConcepts Content and Items · Esri/arcgis-pro-sdk Wiki · GitHub
In code it would look like this (needless to say you can drop the pmi==null check in your code):
IProjectItem mapX = ItemFactory.Instance.Create(@"c:\temp\TheMap.mapx") as IProjectItem;
IProjectMultiItem pmi = mapX as IProjectMultiItem;
if (pmi == null) MessageBox.Show("Does not implement IProjectMultiItem");
else Project.Current.ImportItem(pmi, false);
Thank Wolfgang Kaiser,
I am aware of that content, but I thought it is only for old arcmap items only.
I didn't know that ImportItem method can be used with mapx as well.
It Solved.