CreateMapPaneAsync(PaneCollection,Map,Nullable<MapViewingMode>,TimeRange) Method
Create and activate a new map pane which is a container for a
ArcGIS.Desktop.Mapping.MapView.
Parameters
- paneCollection
- The project's collection of panes returned from ArcGIS.Desktop.Framework.FrameworkApplication.Panes.
- map
- The map to display in the view.
- viewingMode
- Specifies the perspective of the view.
- timeExtent
- Sets the time extent for the view.
Return Value
A Task returning a map pane.
Find a map within a project and open it
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;
});
}
Open a webmap
Map map = null;
//Assume we get the selected webmap from the Project pane's Portal tab
if (Project.Current.SelectedItems.Count > 0)
{
if (MapFactory.Instance.CanCreateMapFrom(Project.Current.SelectedItems[0]))
{
map = MapFactory.Instance.CreateMapFromItem(Project.Current.SelectedItems[0]);
await ProApp.Panes.CreateMapPaneAsync(map);
}
}
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.