ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / MapFrame Class / SetMap Method
Camera
Example

In This Topic
    SetMap Method
    In This Topic
    Sets the Map associated with the MapFrame. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Sub SetMap( _
       ByVal map As Map _
    ) 
    public void SetMap( 
       Map map
    )

    Parameters

    map
    Camera
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Change the map associated with a map frame
    {
      //Change the map associated with a map frame
      //Find a map frame element from a layout by the map frame's element name
      MapFrame mfrm = layout.FindElement("Map Frame") as MapFrame;
    
      //Note: Must be on QueuedTask.Run
      //Reference map from the project item 
      Map myMap = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(m => m.Name.Equals("Map1")).GetMap();
    
      //Set the map to the map frame
      mfrm.SetMap(map);
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also