ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapProjectItem Class / GetMap Method
Example

In This Topic
    GetMap Method
    In This Topic
    Returns a map by loading it first if necessary. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public Map GetMap()
    Public Function GetMap() As Map

    Return Value

    A Map
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Find a map within a project and open it
    {
      //Finding the first project item with name matches with mapName
      MapProjectItem? mpi = Project.Current.GetItems<MapProjectItem>()
        .FirstOrDefault(m => m.Name.Equals("The Map", StringComparison.CurrentCultureIgnoreCase));
      var mapFromItem = await QueuedTask.Run(() => mpi?.GetMap());
      if (mapFromItem != null)
      {
        //Open the map in a new map pane
        //Must be called from the UI thread
        await ProApp.Panes.CreateMapPaneAsync(map);
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also