The new ArcGIS Pro SDK for .NET is currently in beta for ArcGIS Pro 1.1, and I'm having trouble with map/project objects.
I can add layers to an existing map, but I can't seem to figure out how to add a new map to the project:
public async void AddMapToProject()
{
//create new map and set basemap layer
Map mymap = new Map("MapName");
mymap.SetBasemapLayers(Basemap.Oceans);
//there's also Map.Create("MapName"), not sure which to use
//access current project
Project myproject = Project.Current;
//this doesn't work
await myproject.AddAsync(mymap);
//project has AddAsync(Item item) method, but I don't think
//this is for adding maps as it doesn't accept a map object and
//ArcGIS.Desktop.Core.Item.Create(map.uri) doesn't work
}
Any ideas? Can't seem to find an example or the correct method anywhere. The API reference for the SDK is here but doesn't offer many examples. Couldn't find much in the github samples / community samples either.
Best Answer
I think the beta doc might be a little out of date. I was told to look at the factory methods. (
MapFactory.Create
,ItemFactory.Create
, etc which will be the way to go when the SDK is released at 1.1)Try this: (note, the map is created in the projectpane, but is not automatically opened)
Actually, try this nicer code snippet that opens the new map: