Skip To Content ArcGIS for Developers Sign In Dashboard

Save a map

You can create a map by building a new map or by using an existing map, as described in Display a map. Once constructed, the map includes both properties, for example:

  • Map title and description
  • Copyright information
  • A thumbnail image
  • Ratings

and map content, for example:

  • The map's basemap
  • A list of operational layers
  • Information about layer visibility and rendering
  • Layer scale thresholds
  • The map's initial viewpoints

No matter how you create this map you can save it either as a brand new map or, if you have made any changes to the map, you can save it back to its original map. This topic describes how to save a brand new map and how to save back any changes you've made to an existing map.

Save a new map to a portal

When you save a new map to the portal you will create a new portal item with a type of WebMap that has a new unique item ID. The new portal item will be placed in the My Content area of the user that was authenticated with the portal. When you save the map for the first time you must provide at least a map title and a loaded portal object. You can also set these properties if you wish.

  • Tags—an array of tag strings to be used when users search for maps in ArcGIS Online or ArcGIS Enterprise.
  • Folder—a portal folder in which the map will be placed in My Content. By default the map will be saved to the user's root folder.
  • Description—a description of the map.
  • Thumbnail—an image ( via URL) that will be associated with the portal item and is shown on the portal item details page in ArcGIS Online or ArcGIS Enterprise.
  • Force save to supported version—a boolean flag to indicate whether or not the map should be saved as the web map version supported by the API. This may cause data loss, as data unknown to the supported format will be lost when the map is saved.

The following example shows how to save a map as a PortalItem object.

First, connect to the signal that will be emitted when saveAs is complete.

connect(map, &Map::saveAsCompleted, [this, &taskIdFromSignal, &success](QUuid taskId, bool succeeded)
    taskIdFromSignal = taskId;
    success = succeeded;
    emit saveComplete();

Then, decide on the tags, title and description you want for the portal item, and call saveAs on the map object.

QStringList tags = QStringList() << "WebMap" << "Drug Arrests" << "MyAtlas";
QString title("Area Drug Arrests");
QString description("All drug arrests in the area");
QUuid taskId = map->saveAs(m_portal, title, tags, false, PortalFolder(), description);

Access the map's item properties

After the map saving has completed, the map’s portal item property is populated with the brand new portal item properties. You can access all of the properties and set any of the writeable properties, as you require.

qDebug() << "Map description: " << map->item()->description();
qDebug() << "Map modified on: " << map->item()->modified();

map->item()->setDescription("Drug arrests map");

If you wish to save any of these properties, call the map's save method as described in the following section.

Share the map

After the map has been saved to the portal, the map is available to share with other portal users. See Share a portal item for more information.

Save changes to an existing web map

If you have opened a map, made changes to the map content or properties, and you want to save changes back to that map, then call the asynchronous save method on the map. This method, of course, requires that the map has been previously saved to the portal and an exception will be raised if it has not. If a layer in your map allows users to edit offline, be sure to sync their offline edits in addition to saving the map.

First, connect to the signal that could be generated when saving a map.

connect(map, &Map::errorOccurred, this, [this](Error error){ qDebug() << error.message(); });

connect(map, &Map::saveCompleted, this, [this, &taskIdFromSignal, &success](QUuid taskId, bool succeeded)
    qDebug() << "Map was saved.";
    // ...

Then, call the save method on the map.

QUuid taskId = map->save(true);