Select to view content in your preferred language

How to add mapx silently without opening tab

573
3
Jump to solution
08-06-2020 05:25 PM
by Anonymous User
Not applicable

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
0 Kudos
1 Solution

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

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);

View solution in original post

3 Replies
by Anonymous User
Not applicable

Any idea ArcGIS Pro SDK

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

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);
by Anonymous User
Not applicable

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.

0 Kudos