Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for Qt

Display layer view draw state

Sample Viewer View Sample on GitHub

Determine if a layer is currently being viewed.

Use case

The view status includes information on the loading state of layers and whether layers are visible at a given scale. You might change how a layer is displayed in a layer list to communicate whether it is being viewed in the map. For example, you could show a loading spinner next to its name when the view status is Loading, grey out the name when NotVisible or OutOfScale, show the name normally when Active, or with a warning or error icon when the status is Warning or Error.

How to use the sample

Tap Load layer to create a new layer and add it to the map. As you pan and zoom around the map, note how the Enums.LayerViewStatus flags change; for example, Enums.LayerViewStatusOutOfScale becomes true when the map is scaled outside of the layer's min and max scale range. Tap Hide layer to hide the layer and observe the view state change to Enums.LayerViewStatusNotVisible.

How it works

  1. Create an Map with some operational layers.
  2. Set the map on a MapView.
  3. Connect to the layerViewStateChanged signal from the map view.
  4. Display the LayerViewStatus flag for the FeatureLayer.

Relevant API

  • Enums.LayerViewStatus
  • LayerViewState
  • Map
  • MapView
  • MapView.layerViewStateChanged

About the data

The Satellite (MODIS) Thermal Hotspots and Fire Activity layer presents detectable thermal activity from MODIS satellites for the last 48 hours. MODIS Global Fires is a product of NASA’s Earth Observing System Data and Information System (EOSDIS), part of NASA's Earth Science Data. EOSDIS integrates remote sensing and GIS technologies to deliver global MODIS hotspot/fire locations to natural resource managers and other stakeholders around the World.

Additional information

The following are members of the LayerViewStatus enum:

  • Enums.LayerViewStatusActive: The layer in the view is active.
  • Enums.LayerViewStatusNotVisible: The layer in the view is not visible.
  • Enums.LayerViewStatusOutOfScale: The layer in the view is out of scale. A status of Enums.LayerViewStatusOutOfScale indicates that the view is zoomed outside of the scale range of the layer. If the view is zoomed too far in (e.g. to a street level), it is beyond the max scale defined for the layer. If the view has zoomed too far out (e.g. to global scale), it is beyond the min scale defined for the layer.
  • Enums.LayerViewStatusLoading: The layer in the view is loading. Once loading has completed, the layer will be available for display in the view. If there was a problem loading the layer, the status will be set to ERROR.
  • Enums.LayerViewStatusError: The layer in the view has an unrecoverable error. When the status is Enums.LayerViewStatusError, the layer cannot be rendered in the view. For example, it may have failed to load, be an unsupported layer type, or contain invalid data.
  • Enums.LayerViewStatusWarning: The layer in the view has a non-breaking problem with its display, such as incomplete information (eg. by requesting more features than the max feature count of a service) or a network request failure.

If your device supports airplane mode, you can toggle this on and pan around the map to see layers display the WARNING status when they cannot online fetch data. Toggle airplane mode back off to see the warning disappear.


layer, load, map, status, view, visibility

Sample Code

import QtQuick 2.6
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import Esri.ArcGISRuntime 100.9
import Esri.ArcGISRuntime.Toolkit.Dialogs 100.9

Rectangle {
    id: rootRectangle
    clip: true
    width: 800
    height: 600

    readonly property string portalItemId: "b8f4033069f141729ffb298b7418b653"
    property var statusStringList: []
    property var warningMessage: ""

    MapView {
        id: mapView
        anchors.fill: parent

        Map {
            BasemapTopographic {}

            FeatureLayer {
                id: featureLayer
                serviceLayerIdAsInt: 0
                minScale: 400000000
                maxScale: 400000000 / 10
                visible: loadLayerButton.text === qsTr("Hide Layer") ? true : false

                PortalItem {
                    id: portalItem
                    itemId: portalItemId

                // once loaded set the viewpoint
                onLoadStatusChanged: {
                    if (loadStatus !== Enums.LoadStatusLoaded)


        Dialog {
            id: warningDialog
            anchors.centerIn: parent
            standardButtons: Dialog.Ok
            visible: warningMessage !== "" ? true : false
            Text {
                id: warningText
                text: warningMessage;

        onLayerViewStateChanged: {
            // only update list if the layer is the feature layer.
            if ( !=

            // clear list for new view state(s).
            statusStringList = [];

            if (layerViewState.statusFlags & Enums.LayerViewStatusActive) {
            if (layerViewState.statusFlags & Enums.LayerViewStatusError) {
            if (layerViewState.statusFlags & Enums.LayerViewStatusLoading) {
            if (layerViewState.statusFlags & Enums.LayerViewStatusNotVisible) {
            if (layerViewState.statusFlags & Enums.LayerViewStatusOutOfScale) {
            if (layerViewState.statusFlags & Enums.LayerViewStatusWarning) {
                warningMessage = qsTr("Warning message: %1".arg(layerViewState.loadError.message));

            layerViewStatusRepeater.model = statusStringList;

        Rectangle {
            id: controlRect
            anchors {
                horizontalCenter: parent.horizontalCenter
                margins: 5
            width: childrenRect.width
            height: childrenRect.height
            color: "#1976D2"
            radius: 3

            MouseArea {
                width: controlLayout.childrenRect.width
                height: controlLayout.childrenRect.height
                onClicked: mouse.accepted = true;
                onWheel: wheel.accepted = true;

                id: controlLayout

                Text {
                    id: textHeader
                    text: qsTr("Current view status:")
                    color: "white"
                    Layout.alignment: Qt.AlignHCenter

                Column {
                    id: column
                    Layout.alignment: Qt.AlignHCenter
                    Repeater {
                        id: layerViewStatusRepeater
                        Item {
                            width: childrenRect.width
                            height: childrenRect.height
                            Text {
                                text: modelData
                                color: "white"

        Button {
            id: loadLayerButton
            anchors {
                bottom: mapView.attributionTop
                horizontalCenter: parent.horizontalCenter
                margins: 5
            text: qsTr("Load Layer")
            enabled: featureLayer.loadStatus !== Enums.LoadStatusLoading ? true : false
            clip: true
            onClicked: {
                if (text === qsTr("Load Layer")) {
                    // load a feature layer from a portal item
                    text = qsTr("Hide Layer");
                else if (text === qsTr("Hide Layer"))
                    text = qsTr("Show Layer");
                else if (text === qsTr("Show Layer"))
                    text = qsTr("Hide Layer");

    Point {
        id: viewPoint
        x: -11000000
        y: 4500000
        spatialReference: Factory.SpatialReference.createWebMercator();