Create and save a map as a web map item to an ArcGIS portal.

Use case
Maps can be created programmatically in code and then serialized and saved as an ArcGIS portal item. In this case, the portal item is a web map which can be shared with others and opened in various applications and APIs throughout the platform, such as ArcGIS Pro, ArcGIS Online, the JavaScript API, and Field Maps.
How to use the sample
When you run the sample, you will be challenged for an ArcGIS Online login. Enter a username and password for an ArcGIS Online named user account (such as your ArcGIS for Developers account). Then, choose the basemap and layers for your new map. To save the map, add a title, tags, and description (optional), and a folder on your portal (you will need to create one in your portal’s My Content section if you don’t already have one). Click the Save button to save the map to the chosen folder.
How it works
- Set up the authenticator the manage authentication challenges.
- Create a new
Portalwith an authenticated connection and load it. - Log in to the portal.
- Access the
PortalUser.Contentwithportal.user.content, to get the user’s list of portal folders. - Create a
Mapwith the specifiedBasemapStyleand operational data. - Call
Map.save(to:title:forceSaveToSupportedVersion:folder:description:thumbnail:tags:extent:)to save the configuredMapwith the specified title, tags, description, and folder to the portal.
Relevant API
- ArcGISMapImageLayer
- BasemapStyle
- Map
- Portal
Tags
ArcGIS Online, ArcGIS Pro, portal, publish, share, web map