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

SaveAsWebMapFile(String) Method
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
)

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