ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / MapSeries Class / CreateSpatialMapSeries Method
The Layout you will ultimately apply the map series.
The MapFrame that contains the index layer.
A BasicFeatureLayer that include a point, line or polygon attribute table.
A String that represents the Name field in the index layer that should uniquely identify each page.
Example

In This Topic
    CreateSpatialMapSeries Method
    In This Topic
    Creates a spatial map series. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Shared Function CreateSpatialMapSeries( _
       ByVal layout As Layout, _
       Optional ByVal mapFrame As MapFrame, _
       Optional ByVal indexLayer As BasicFeatureLayer, _
       Optional ByVal nameField As String _
    ) As SpatialMapSeries

    Parameters

    layout
    The Layout you will ultimately apply the map series.
    mapFrame
    The MapFrame that contains the index layer.
    indexLayer
    A BasicFeatureLayer that include a point, line or polygon attribute table.
    nameField
    A String that represents the Name field in the index layer that should uniquely identify each page.

    Return Value

    Exceptions
    ExceptionDescription
    This method must be called within the lambda passed to QueuedTask.Run.
    Remarks
    This method allows you to create a new spatial map series using a minimum number of required paramters. It returns a CIMSpatialMapSeries object that can be further modified using fine grained properties. To apply the changes to the layout, use the SetMapSeries() method.
    Example
    Create a new spatial map series
    // This example create a new spatial map series and then applies it to the active layout. This will automatically 
    // overwrite an existing map series if one is already present.
    
    //Reference map frame and index layer
    MapFrame mf = layout.FindElement("Map Frame") as MapFrame;
    Map m = mf.Map;
    BasicFeatureLayer indexLyr = m.FindLayers("Countries").FirstOrDefault() as BasicFeatureLayer;
    
    //Construct map series on worker thread
    await QueuedTask.Run(() =>
    {
      //SpatialMapSeries constructor - required parameters
      SpatialMapSeries SMS = MapSeries.CreateSpatialMapSeries(layout, mf, indexLyr, "Name");
      
      //Set optional, non-default values
      SMS.CategoryField = "Continent";
      SMS.SortField = "Population";
      SMS.ExtentOptions = ExtentFitType.BestFit;
      SMS.MarginType = ArcGIS.Core.CIM.UnitType.PageUnits;
      SMS.MarginUnits = ArcGIS.Core.Geometry.LinearUnit.Centimeters;
      SMS.Margin = 1;
      SMS.ScaleRounding = 1000;
      layout.SetMapSeries(SMS);  //Overwrite existing map series.
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also