Map Class

  • Map
  • class Esri::ArcGISRuntime::Map

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

    Header: #include <Map.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: Esri::ArcGISRuntime::GeoModel and Esri::ArcGISRuntime::JsonSerializable

    This class was introduced in Esri::ArcGISRuntime 100.0.

    Public Functions

    Map(Esri::ArcGISRuntime::BasemapStyle basemapStyle, QObject *parent = nullptr)
    Map(const Esri::ArcGISRuntime::SpatialReference &spatialReference, QObject *parent = nullptr)
    Map(Esri::ArcGISRuntime::Item *item, QObject *parent = nullptr)
    Map(Esri::ArcGISRuntime::Basemap *basemap, QObject *parent = nullptr)
    Map(const QUrl &url, QObject *parent = nullptr)
    Map(QObject *parent = nullptr)
    virtual ~Map() override
    QColor backgroundColor() const
    Esri::ArcGISRuntime::Envelope maxExtent() const
    double maxScale() const
    double minScale() const
    Esri::ArcGISRuntime::TaskWatcher namedTraceConfigurationsFromUtilityNetwork(Esri::ArcGISRuntime::UtilityNetwork *utilityNetwork)
    Esri::ArcGISRuntime::OfflineSettings *offlineSettings() const
    double referenceScale() const
    QUuid save(bool forceSaveToSupportedVersion)
    QUuid saveAs(Esri::ArcGISRuntime::Portal *portal, const QString &title, const QStringList &tags, bool forceSaveToSupportedVersion, const Esri::ArcGISRuntime::PortalFolder &folder = PortalFolder(), const QString &description = QString(), const QByteArray &thumbnailBytes = QByteArray())
    void setBackgroundColor(const QColor &backgroundColor)
    void setMaxExtent(const Esri::ArcGISRuntime::Envelope &maxExtent)
    void setMaxScale(double scale)
    void setMinScale(double scale)
    void setReferenceScale(double scale)
    Esri::ArcGISRuntime::UtilityNetworkListModel *utilityNetworks() const

    Reimplemented Public Functions

    virtual QString toJson() const override
    virtual QJsonObject unknownJson() const override
    virtual QJsonObject unsupportedJson() const override

    Signals

    void namedTraceConfigurationsFromUtilityNetworkCompleted(QUuid taskId, const QList<Esri::ArcGISRuntime::UtilityNamedTraceConfiguration *> &namedTraceConfigurationsResults)
    void saveAsCompleted(QUuid taskId, bool succeeded)
    void saveCompleted(QUuid taskId, bool succeeded)

    Static Public Members

    Esri::ArcGISRuntime::Map *fromJson(const QString &json, QObject *parent = nullptr)

    Detailed Description

    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(Esri::ArcGISRuntime::BasemapStyle basemapStyle, QObject *parent = nullptr)

    Constructor that creates a map with a basemap style.

    • basemapStyle - The basemap style.
    • parent - The optional parent QObject.

    This function was introduced in Esri::ArcGISRuntime 100.10.

    See also BasemapStyle.

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

    Constructor that takes a spatialReference with an optional parent.

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

    Constructor that takes an item with an optional parent.

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

    Constructor that takes a basemap with an optional parent.

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

    Creates a map based on the given URL to a webmap. A PortalItem will be created to reference the webmap and accessible through item.

    • url - URL of a webmap on ArcGIS Online or ArcGIS Enterprise portal.
    • parent - The optional parent QObject.

    The supported URL formats are:

    See also PortalItem, PortalItem::PortalItem(QUrl), and GeoModel::item.

    Map::Map(QObject *parent = nullptr)

    Default constructor that creates a map.

    • parent - The optional parent QObject.

    See also GeoModel::load and SpatialReference.

    [signal] void Map::namedTraceConfigurationsFromUtilityNetworkCompleted(QUuid taskId, const QList<Esri::ArcGISRuntime::UtilityNamedTraceConfiguration *> &namedTraceConfigurationsResults)

    Signal emitted when the namedTraceConfigurationsFromUtilityNetwork operation completes.

    • taskId - The task ID of the asynchronous operation.
    • namedTraceConfigurationsResults.

    This function was introduced in Esri::ArcGISRuntime 100.11.

    [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.

    [override virtual] Map::~Map()

    Destructor.

    QColor Map::backgroundColor() const

    The background color of the map.

    This value determines the color to be displayed behind the map. This color will be displayed in transparent areas of the map as well as areas where there is no basemap or operational data.

    When a map is set on a MapView, changes to backgroundColor will immediately take effect.

    The default value is an invalid QColor. In this case, the MapView::backgroundGrid is used to determine the background color to display.

    This function was introduced in Esri::ArcGISRuntime 100.7.

    See also setBackgroundColor().

    [static] Esri::ArcGISRuntime::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.

    Esri::ArcGISRuntime::Envelope Map::maxExtent() const

    Returns the extent that constrains the display to a specific region. The max extent is initialized when the map loads with the union of the full extent of all basemap layers, or with the first operational layer's full extent if the map has no basemap. Will be an Envelope that is not valid if the map is not loaded and if the max extent has not been explicitly set.

    This function was introduced in Esri::ArcGISRuntime 100.14.

    See also setMaxExtent().

    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().

    Esri::ArcGISRuntime::TaskWatcher Map::namedTraceConfigurationsFromUtilityNetwork(Esri::ArcGISRuntime::UtilityNetwork *utilityNetwork)

    Returns a list of all the UtilityNamedTraceConfiguration objects referenced by UtilityNetwork's Map.

    An empty QList will be returned if the UtilityNetwork does not belong to the Map or if the Map does not contain any UtilityNamedTraceConfiguration objects. If the UtilityNetwork is not loaded, an error will be returned.

    Returns a TaskWatcher for the asynchronous operation.

    This function was introduced in Esri::ArcGISRuntime 100.11.

    See also UtilityNamedTraceConfiguration.

    Esri::ArcGISRuntime::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.

    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().

    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(Esri::ArcGISRuntime::Portal *portal, const QString &title, const QStringList &tags, bool forceSaveToSupportedVersion, const Esri::ArcGISRuntime::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.

    void Map::setBackgroundColor(const QColor &backgroundColor)

    Sets the background color to backgroundColor.

    To clear the background color, pass a default constructed (invalid) QColor.

    This function was introduced in Esri::ArcGISRuntime 100.7.

    See also backgroundColor().

    void Map::setMaxExtent(const Esri::ArcGISRuntime::Envelope &maxExtent)

    Sets the maxExtent to maxExtent.

    This function was introduced in Esri::ArcGISRuntime 100.14.

    See also maxExtent.

    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().

    [override virtual] QString Map::toJson() const

    Reimplements: JsonSerializable::toJson() const.

    Returns this Map instance represented as a JSON String.

    See also JsonSerializable.

    [override virtual] QJsonObject Map::unknownJson() const

    Reimplements: JsonSerializable::unknownJson() const.

    Gets the unknown JSON of this object.

    See also JsonSerializable.

    [override virtual] QJsonObject Map::unsupportedJson() const

    Reimplements: JsonSerializable::unsupportedJson() const.

    Gets the unsupported JSON of this object.

    See also JsonSerializable.

    Esri::ArcGISRuntime::UtilityNetworkListModel *Map::utilityNetworks() const

    Returns the utility networks in the map.

    This collection of UtilityNetwork is specific to this map.

    A Map created with a webmap portal item that has utility networks will pre-populate this collection.

    When this Map is used to create a UtilityNetwork, the UtilityNetwork that was created will be added to this collection.

    Only a UtilityNetwork that is not loaded may be added to this collection. An attempt to add a UtilityNetwork that is loaded or loading will throw an error.

    An attempt to add to this collection, a UtilityNetwork that is already part of a Map::utilityNetworks(), will throw an error.

    An attempt to add a nullptr UtilityNetwork to this collection will throw an error.

    This function was introduced in Esri::ArcGISRuntime 100.10.

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.