Skip To Content ArcGIS for Developers Sign In Dashboard

Map Class

(Esri::ArcGISRuntime::Map)

A map that can be displayed on the screen by the mapview. More...

Header: #include <Map>
Since: Esri::ArcGISRuntime 100.0
Inherits: Object, Loadable, and JsonSerializable

Public Functions

Map(QObject *parent = nullptr)
Map(const QUrl &url, QObject *parent = nullptr)
Map(Basemap *basemap, QObject *parent = nullptr)
Map(BasemapType basemapType, double latitude, double longitude, int levelOfDetail, QObject *parent = nullptr)
Map(Item *item, QObject *parent = nullptr)
Map(const SpatialReference &spatialReference, QObject *parent = nullptr)
~Map()
Basemap *basemap() const
BookmarkListModel *bookmarks() const
Viewpoint initialViewpoint() const
bool isAutoFetchLegendInfos() const
Item *item() const
LegendInfoListModel *legendInfos() const
LoadSettings *loadSettings() const
double maxScale() const
double minScale() const
OfflineSettings *offlineSettings() const
LayerListModel *operationalLayers() const
double referenceScale() const
QUuid save(bool forceSaveToSupportedVersion)
QUuid saveAs(Portal *portal, const QString &title, const QStringList &tags, bool forceSaveToSupportedVersion, const PortalFolder &folder = PortalFolder(), const QString &description = QString(), const QByteArray &thumbnailBytes = QByteArray())
void setAutoFetchLegendInfos(bool autoFetchLegendInfos)
void setBasemap(Basemap *basemap)
void setInitialViewpoint(const Viewpoint &viewpoint)
void setLoadSettings(LoadSettings *settings)
void setMaxScale(double scale)
void setMinScale(double scale)
void setReferenceScale(double scale)
SpatialReference spatialReference() const
FeatureTableListModel *tables() const
QList<TransportationNetworkDataset *> transportationNetworks() const
QString version() const

Reimplemented Public Functions

virtual void cancelLoad()
virtual void load()
virtual Error loadError() const
virtual LoadStatus loadStatus() const
virtual void retryLoad()
virtual QString toJson() const
virtual QJsonObject unknownJson() const
virtual QJsonObject unsupportedJson() const

Signals

void basemapChanged(Esri::ArcGISRuntime::Basemap *oldBasemap)
void doneLoading(Esri::ArcGISRuntime::Error loadError)
void loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)
void saveAsCompleted(QUuid taskId, bool succeeded)
void saveCompleted(QUuid taskId, bool succeeded)

Static Public Members

Map *fromJson(const QString &json, QObject *parent = nullptr)
  • 10 static public members inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

A map that can be displayed on the screen by the mapview.

A map represents the model in an MVC architecture and a map view represents the view.

A map specifies how the geographic data is organized, and a map view renders the data and allows users to interact with it.

Conceptually, a map's geographic content is derived from its basemap and operational layers.

A basemap provides a background of geographical context for the content you want to display in the map. It is used for locational reference and provides a framework on which you can overlay operational layers. Thus, the basemap serves as a foundation and provides a framework for working with information geographically. Its content is typically geographic features that are static and do not change frequently, such as streets, parcel boundaries, or rivers.

Operational layers provide content of unique interest to the application and the task at hand. Their content might change frequently, such as earthquake reports, traffic, or weather.

If operational layers are added to an existing map before the map is loaded, the map's original list of operational layers is overridden to only contain the added layers. To keep the map's original operational layers and also add new ones, wait until the map is done loading before adding operational layers. You can wait for the doneLoading signal to be emitted before adding the new operational layers.

The map has a spatial reference that specifies how the geographic content from its basemap and operational layers are aligned when combined together.

Once the map has obtained a spatial reference it cannot be changed, even by changing the basemap.

Note: All web maps have a version number that corresponds to the last time the web map was opened and saved. ArcGIS Runtime only supports web maps that are version 2.0 and greater. If you try to load a web map that is older than 2.0, it will fail to load with an error indicating that the web map version is not supported. To upgrade the version of the web map, simply open and save the web map in the ArcGIS Online or ArcGIS Enterprise portal map viewer.

Example:

Create a map from a web map stored in ArcGIS Online:

PortalItem* portalItem = new PortalItem(UrlUtility::url("portalItemHousingWithMortgages", UrlUtility::Live), this);
Map* map = new Map(portalItem, this);

See also JsonSerializable and Loadable.

Member Function Documentation

Map::Map(QObject *parent = nullptr)

Default constructor with an optional parent.

Map::Map(const QUrl &url, QObject *parent = nullptr)

Constructor that takes a url with an optional parent.

The URL can be one of three possible types that refer to a PortalItem:

  • The item details page : http://www.myPortal.com/home/item.html?id=12345678901234567890123456789012
  • The map view page : http://www.myPortal.com/home/webmap/viewer.html?webmap=12345678901234567890123456789012
  • The sharing data page : http://www.myPortal.com/sharing/rest/content/items/12345678901234567890123456789012/data

Map::Map(Basemap *basemap, QObject *parent = nullptr)

Constructor that takes a basemap with an optional parent.

Map::Map(BasemapType basemapType, double latitude, double longitude, int levelOfDetail, QObject *parent = nullptr)

Constructor that takes basemap type, center point, and level-of-detail.

  • basemapType - The type of basemap you want to use.
  • latitude - The latitude of the center point.
  • longitude - The longitude of the center point.
  • levelOfDetail - the level of detail or initial zoom level.
  • parent - The optional parent.

Map::Map(Item *item, QObject *parent = nullptr)

Constructor that takes an item with an optional parent.

Map::Map(const SpatialReference &spatialReference, QObject *parent = nullptr)

Constructor that takes a spatialReference with an optional parent.

Map::~Map()

Destructor.

Basemap *Map::basemap() const

Gets the basemap.

See also setBasemap().

[signal] void Map::basemapChanged(Esri::ArcGISRuntime::Basemap *oldBasemap)

The signal emitted when the basemap changes.

  • oldBasemap - The previous basemap.

The returned Basemap object has the Map as its parent.

See also Returned QObjects Parenting.

BookmarkListModel *Map::bookmarks() const

Gets the bookmarks list model for the Map.

The Map only supports BoundingGeometry viewpoints types (declared with an extent). CenterAndScale viewpoints (declared around a center point) are not supported in the Map.

[virtual] void Map::cancelLoad()

Reimplemented from Loadable::cancelLoad().

See Loadable.

[signal] void Map::doneLoading(Esri::ArcGISRuntime::Error loadError)

Signal emitted when this object is done loading.

  • loadError - Details about any error that may have occurred.

Note: If there is a load error it will also be emitted on the errorOccurred signal.

See also Loadable and Object.

[static] Map *Map::fromJson(const QString &json, QObject *parent = nullptr)

Creates this Map from its JSON representation.

Returns a Map created using the data in the json parameter and an optional parent.

See also JsonSerializable.

Viewpoint Map::initialViewpoint() const

Gets the initial Viewpoint.

See also setInitialViewpoint().

bool Map::isAutoFetchLegendInfos() const

Gets whether legend infos are automatically fetched by the operational layers in the map.

Returns true if legend infos will be fetched automatically when the LegendInfoListModel is instantiated.

Item *Map::item() const

Returns the item used to construct this Map object, if any.

LegendInfoListModel *Map::legendInfos() const

Gets a list model containing legend infos for the map's operational layers and any sublayers.

Returns a LegendInfoListModel representing the legend information for the map's operational layers and their sublayers.

[virtual] void Map::load()

Reimplemented from Loadable::load().

See Loadable.

[virtual] Error Map::loadError() const

Reimplemented from Loadable::loadError().

See Loadable.

LoadSettings *Map::loadSettings() const

Gets the load settings properties that can be used to make changes to how feature layers, which are loaded by this map, are rendered.

This function was introduced in Esri::ArcGISRuntime 100.2.

See also setLoadSettings().

[virtual] LoadStatus Map::loadStatus() const

Reimplemented from Loadable::loadStatus().

See Loadable.

[signal] void Map::loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)

Signal emitted when the load status changes for this object.

See also Loadable.

double Map::maxScale() const

Returns the maximum scale of the map.

The default value is 0.0.

See also setMaxScale().

double Map::minScale() const

Returns the minimum scale of the map.

The default value is 0.0.

See also setMinScale().

OfflineSettings *Map::offlineSettings() const

Retrieves the offline use settings, configured by the author of an online web map (if appropriate).

These settings will only be populated when this map represents an online web map and the author has chosen to set them. The properties can be used to inform how a map should be taken offline.

If no online settings were provided, or if this map does not represent an online web map, this property will be nullptr.

This function was introduced in Esri::ArcGISRuntime 100.5.

LayerListModel *Map::operationalLayers() const

Returns the list model of operational layers in the map.

double Map::referenceScale() const

Returns the reference scale of the map.

The reference scale is the scale at which feature symbols and text will appear at their default size. If the viewing scale is different from the reference scale, then the symbology and text graphics will be scaled to keep the same size on the map. Only those layers which isScaleSymbols is true will be scaled.

The default value is 0.0. Zero reference scale means that no reference scale is set and all symbology and text graphics will be drawn at their default screen size.

Negative/NaN values have no meaning, and will be rejected.

This function was introduced in Esri::ArcGISRuntime 100.5.

See also setReferenceScale().

[virtual] void Map::retryLoad()

Reimplemented from Loadable::retryLoad().

See Loadable.

QUuid Map::save(bool forceSaveToSupportedVersion)

Saves any changes that have been made to the map.

The map must have been constructed using the PortalItem constructor, or been saved using saveAs to associate it with a PortalItem object.

  • forceSaveToSupportedVersion - Whether the map should be saved to the supported web map version that the API supports (see system requirements). This may cause data loss as unknown data is not saved. If true, unknown data will be removed and the map will be saved. If false, the asynchronous operation will fail if the map contains unknown data that will not be saved. This flag can be used to provide a warning to users that some map data may be lost when the map is saved.

Updates the map content data on the portal and also updates the portal item properties stored on the portal to match those stored within the map's PortalItem object.

If the portal is not loaded, it will be loaded automatically. If the portal requires a credential that has not been supplied, it should be loaded before calling this function.

The map must be loaded to call this function. Calling this function will not force the map to start loading. If the map is not already associated with a PortalItem, calling save will produce an error.

QUuid Map::saveAs(Portal *portal, const QString &title, const QStringList &tags, bool forceSaveToSupportedVersion, const PortalFolder &folder = PortalFolder(), const QString &description = QString(), const QByteArray &thumbnailBytes = QByteArray())

Saves the map to a portal as a portalItem.

  • portal - The portal to save the PortalItem to.
  • title - A title for the map.
  • tags - A list of tags to associate with the map.
  • forceSaveToSupportedVersion - Whether the map should be saved to the supported web map version that the API supports (see system requirements). This may cause data loss as unknown data is not saved. If true, unknown data will be removed and the map will be saved. If false, the asynchronous operation will fail if the map contains unknown data that will not be saved. This flag can be used to provide a warning to users that some map data may be lost when the map is saved.
  • folder - An optional PortalFolder belonging to the current user in which to save the map. If not specified the map will be saved in the user's root folder.
  • description - An optional description for the map.
  • thumbnailBytes - Optional bytes for the thumbnail image.

Updates the map content data on the portal, and updates the portal item properties stored on the portal to match those stored within the map's PortalItem object.

If the portal is not loaded, it will be loaded automatically. If the portal requires a credential that has not been supplied, it should be loaded before calling this function.

The map must be loaded to call this function. Calling this function will not force the map to start loading.

[signal] void Map::saveAsCompleted(QUuid taskId, bool succeeded)

The signal emitted when the saveAs operation completes.

  • taskId - The async task ID.
  • succeeded - Whether the async operation succeeded.

[signal] void Map::saveCompleted(QUuid taskId, bool succeeded)

The signal emitted when the save operation completes.

  • taskId - The async task ID.
  • succeeded - Whether the async operation succeeded.

void Map::setAutoFetchLegendInfos(bool autoFetchLegendInfos)

Sets whether legend infos are automatically fetched by the operational layers in the map.

Set autoFetchLegendInfos to true to have legend infos fetched automatically when the LegendInfoListModel is instantiated.

See also isAutoFetchLegendInfos().

void Map::setBasemap(Basemap *basemap)

Sets the basemap.

See also basemap().

void Map::setInitialViewpoint(const Viewpoint &viewpoint)

Sets the initial viewpoint.

See also initialViewpoint().

void Map::setLoadSettings(LoadSettings *settings)

Sets the load settings for this map to settings.

The load settings change how feature layers, loaded by this map, are rendered.

This function was introduced in Esri::ArcGISRuntime 100.2.

See also loadSettings().

void Map::setMaxScale(double scale)

Sets the maximum scale of the map.

Setting this to zero means that there is no maximum scale, and the user can zoom in indefinitely.

See also maxScale().

void Map::setMinScale(double scale)

Sets the minimum scale of the map.

Setting this to zero means that there is no minumum scale, and the user can zoom out indefinitely.

See also minScale().

void Map::setReferenceScale(double scale)

Sets the reference scale of the map.

The reference scale is the scale at which feature symbols and text will appear at their default size. If the viewing scale is different from the reference scale, then the symbology and text graphics will be scaled to keep the same size on the map. Only those layers which have drawingInfo.scaleSymbols=true will be scaled.

The default value is 0.0. Zero reference scale means that no reference scale is set and all symbology and text graphics will be drawn at their default screen size.

Negative/NaN values have no meaning, and will be rejected.

This function was introduced in Esri::ArcGISRuntime 100.5.

See also referenceScale().

SpatialReference Map::spatialReference() const

Gets the spatial reference.

FeatureTableListModel *Map::tables() const

Returns a list of non-spatial tables in the map.

Tables can be added and removed from the map through this model.

Tables are not loaded by default. Tables are loaded internally when asynchronous operations like query are performed. Alternatively, they can be loaded by calling load on each table.

This function was introduced in Esri::ArcGISRuntime 100.1.

[virtual] QString Map::toJson() const

Reimplemented from JsonSerializable::toJson().

Returns this Map instance represented as a JSON String.

See also JsonSerializable.

QList<TransportationNetworkDataset *> Map::transportationNetworks() const

Gets an unmodifiable list of transportation networks.

Returns a list of TransportationNetworkDataset.

[virtual] QJsonObject Map::unknownJson() const

Reimplemented from JsonSerializable::unknownJson().

Gets the unknown JSON of this object.

See also JsonSerializable.

[virtual] QJsonObject Map::unsupportedJson() const

Reimplemented from JsonSerializable::unsupportedJson().

Gets the unsupported JSON of this object.

See also JsonSerializable.

QString Map::version() const

Returns the version information.


Feedback on this topic?