ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / IElementFactory Interface / CreateMapFrameElement Method
The parent element container
The map frame location, envelope, or polygon
The map (to be) associated with the frame (can be null)
An element name (optional)
Select after create flag (default is true) (optional)
Additional element properties (optional)
Example

In This Topic
    CreateMapFrameElement Method (IElementFactory)
    In This Topic
    Create a map frame element based on the input map frame polygon and map URI.
    Syntax
    Function CreateMapFrameElement( _
       ByVal elementContainer As IElementContainer, _
       ByVal frameOrLocation As Geometry, _
       ByVal map As Map, _
       Optional ByVal elementName As String, _
       Optional ByVal select As Boolean, _
       Optional ByVal elementInfo As ElementInfo _
    ) As MapFrame

    Parameters

    elementContainer
    The parent element container
    frameOrLocation
    The map frame location, envelope, or polygon
    map
    The map (to be) associated with the frame (can be null)
    elementName
    An element name (optional)
    select
    Select after create flag (default is true) (optional)
    elementInfo
    Additional element properties (optional)

    Return Value

    Remarks
    Graphic layers are not valid containers for map frames.
    If a point is provided as the frame geometry then a default extent will be applied.
    Example
    Create_MapFrame
    //Creates a new map frame and changes the camera's scale.
    
    //Constuct on the worker thread
    await QueuedTask.Run(() =>
    {
      //Build geometry
      Coordinate2D ll = new Coordinate2D(6.0, 8.5);
      Coordinate2D ur = new Coordinate2D(8.0, 10.5);
      //At 2.x - Envelope env = EnvelopeBuilder.CreateEnvelope(ll, ur);
      Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur);
    
      //Reference map, create MF and add to layout
      MapProjectItem mapPrjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name.Equals("Map"));
      Map mfMap = mapPrjItem.GetMap();
      //At 2.x - mfElm = LayoutElementFactory.Instance.CreateMapFrame(layout, env, mfMap);
      //         mfElm.SetName("New Map Frame"); 
      mfElm = ElementFactory.Instance.CreateMapFrameElement(layout, env, mfMap, "New Map Frame");
    
      //Set the camera
      Camera camera = mfElm.Camera;
      camera.Scale = 24000;
      mfElm.SetCamera(camera);
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also