ArcGIS Runtime SDK for Qt

Token authentication

Loading

Code

import QtQuick 2.6
import QtQuick.Controls 1.4
import Esri.ArcGISRuntime 100.3
import Esri.ArcGISRuntime.Toolkit.Dialogs 100.3
import Esri.ArcGISExtras 1.1

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

    property real scaleFactor: System.displayScaleFactor

    MapView {
        id: mapView
        anchors.fill: parent


        Map {
            id: map
            BasemapTopographic {}

            ViewpointExtent {
                Envelope {
                    json: {"spatialReference":{"latestWkid":3857,"wkid":102100},
                           "xmax":-3024411.4154897667,
                           "xmin":-19221397.32591107,
                           "ymax":11939432.83566906,
                           "ymin":-208306.59714691807
                    }
                }
            }
        }       

        Column {
            anchors {
                horizontalCenter: parent.horizontalCenter
                bottom: mapView.attributionTop
                margins: 10 * scaleFactor
            }
            spacing: 10 * scaleFactor

            Text {
                anchors.horizontalCenter: parent.horizontalCenter
                font.pixelSize: 14 * scaleFactor
                text: "username/password: user1/user1"
            }

            Button {
                anchors.horizontalCenter: parent.horizontalCenter
                text: "Load Secured Layer"
                onClicked: map.operationalLayers.append(mapImagelayer);
            }
        }
    }

    // add a map service that is secured with token-based authentication
    // username/password is user1/user1
    ArcGISMapImageLayer {
        id: mapImagelayer
        url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA_secure_user1/MapServer"
    }


    // Uncomment this section when running as standalone application
    /*
    // Declare an AuthenticationView
    AuthenticationView {
        anchors.fill: parent
        authenticationManager: AuthenticationManager // set the authenticationManager property
    }
    */
}


In this topic
  1. Code