ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Map Class / SaveAsWebMapFile(String) Method
The fullpath of the webmap file to save to
Example

In This Topic
    SaveAsWebMapFile(String) Method
    In This Topic
    Save the current map to webmap file format. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void SaveAsWebMapFile( 
       string webMapFileName
    )
    Public Sub SaveAsWebMapFile( _
       ByVal webMapFileName As String _
    ) 

    Parameters

    webMapFileName
    The fullpath of the webmap file to save to
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    DefaultViewingMode not supported
    Directory does not exist
    The value of webMapFileName cannot be null
    Remarks
    This version currently supports 2D maps: DefaultViewingMode == ArcGIS.Core.CIM.MapViewingMode.Map.
    Only webmap compatible layers will be saved out to the specified file.
    A suffix of ".json" will be appended to the filename if no suffix or a different suffix is provided. If the specified filename exists it will be overwritten.
    Layer symbology is converted to symbology compatible with all web map clients
    Example
    Save 2D Map as WebMap on Disk
    //2D maps only
    //Must be on the QueuedTask.Run(...)
    if (map.DefaultViewingMode == MapViewingMode.Map)
      //Only webmap compatible layers will be saved out to the file
      map.SaveAsWebMapFile(@"C:\Data\MyMap.json");
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also