public static async Task<Map> FindOpenExistingMapAsync(string mapName)
{
return await QueuedTask.Run(async () =>
{
Map map = null;
Project proj = Project.Current;
//Finding the first project item with name matches with mapName
MapProjectItem mpi = proj.GetItems<MapProjectItem>()
.FirstOrDefault(m => m.Name.Equals(mapName, StringComparison.CurrentCultureIgnoreCase));
if (mpi != null)
{
map = mpi.GetMap();
//Opening the map in a mapview
await ProApp.Panes.CreateMapPaneAsync(map);
}
return map;
});
}