AnsweredAssumed Answered

Simple app with private WebMap

Question asked by powerm on Feb 3, 2020
Latest reply on Feb 17, 2020 by craiggad

I am new to Appstudio and Qt. I succeeded in building the Map Viewer (4.1) app with a private web map.

Map Viewer (4.1) is a big (and for me complex) app. With my limited knowledge I am not able to downscale to a 'as simple as possible" app to display a private web map.

 

Whenever I try to load the web map in a simple example application like "Web Map" from the arcgis-appstudio-samples-4.0 Git, a grey screen appears, no error messages.

 

What should I add to be able to show the web map, just as in Map Viewer (4.1)

Company name and item id are changed in this listing

The code:

 

import QtQuick 2.7
import QtQuick.Controls 2.1
import QtQuick.Controls.Styles 1.4
import QtGraphicalEffects 1.0
import QtQuick.Controls.Material 2.1
import ArcGIS.AppFramework 1.0
import ArcGIS.AppFramework.Controls 1.0
import Esri.ArcGISRuntime 100.2
Item {
    property real scaleFactor: AppFramework.displayScaleFactor
    MapView {
        id:mapView
        anchors.fill: parent
        BusyIndicator {
            anchors.centerIn: parent
            height: 48 * scaleFactor
            width: height
            running: true
            Material.accent:"#8f499c"
            visible: (mapView.drawStatus === Enums.DrawStatusInProgress)
        }
    }
    Rectangle {
        anchors.fill: parent
        color: "transparent"
        ComboBox {
            id:combobox
            anchors.left:  parent.left
            anchors.top:  parent.top
            anchors.margins: 10 * scaleFactor
            width: 200 * scaleFactor
            height: 30 * scaleFactor
            clip:true
            Material.accent:"#8f499c"
            background: Rectangle {
                anchors.fill: parent
                radius: 6 * scaleFactor
                border.color: "darkgrey"
                width: 200 * scaleFactor
                height: 30 * scaleFactor
            }
            textRole:"name"
            model: ListModel {
                id: cbItems
                ListElement { name: "MYCOMPANY"; item: "XXXXXXXXXXXXXXXXXXXXXX" }
                ListElement { name: "San Francisco"; item: "358e6f9bebf544699b005f066886579c" }
                ListElement { name: "OpenstreetMap"; item: "0d22c9bc992f4f218605d6edb042ff89" }

 

            }
            onCurrentIndexChanged: {
                loadWebMap(cbItems.get(currentIndex).item)
            }
            Component.onCompleted: {
                loadWebMap(cbItems.get(currentIndex).item)
            }
        }
    }

 

    function loadWebMap(webmapitemid){
        var organizationPortalUrl = "https://mycompany-def.maps.arcgis.com/";
        var webmapUrl = organizationPortalUrl + webmapitemid;
        var newMap = ArcGISRuntimeEnvironment.createObject("Map", {initUrl: webmapUrl, autoFetchLegendInfos:true});
        mapView.map = newMap;
    }
}

Outcomes