MapFactory Instance CreateMap does not add Map to Project

950
2
09-25-2019 06:32 PM
StephenDavis1
New Contributor II

I am trying to add a new map to my Pro project (Pro 2.4.1) via c# and it is not working. My code looks like this:

var map = MapFactory.Instance.CreateMap("New Map", basemap: Basemap.None);

It creates the map object fine (I can access it via c# and add layers to it and save it as a map file), but it does not add the map to the project to be used there.

In the documentation here

ProConcepts Map Authoring · Esri/arcgis-pro-sdk Wiki · GitHub 

It says:

Methods such as MapFactory.Instance.CreateMap() add the newly created map into the current project. You do not need to write additional code for adding a map to a project.

Is there anything else I can try to get this map addes to my project?

0 Kudos
2 Replies
UmaHarano
Esri Regular Contributor

Hi Stephen

To clarify, can you please confirm if you are not able to see the new map in your Project Catalog Pane within the Maps collection like this screenshot below?

The code should add the new map to the Maps collection as you see below.  You will have to actually open the new Map to see it in a Map View (Code here does that). CreateMap method will not open the map. 

Thanks

Uma

0 Kudos
StephenDavis1
New Contributor II

That is correct, Uma. After further research yesterday, the map showed up a couple of times when I ran that line of code. It seems to maybe be more related to the map than the line of code I pointed out, since sometimes it does show up...or maybe something else. I am not seeing consistent behavior with it.

0 Kudos