Simple app with private WebMap

2086
17
Jump to solution
02-03-2020 10:39 AM
Pvan_Herk
New Contributor

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;
    }
}
0 Kudos
17 Replies
ErwinSoekianto
Esri Regular Contributor

This is what the redirect URI value needed for the "Application" in the ArcGIS Online or Enterprise where you get the client ID from. This redirect URI value should be there by default when you create a new one. 

0 Kudos
PHerk
by
New Contributor II

Hi Erwin,

What should I do with this redirect URL, it is not used in your sample app...

Also when I enter a new application at this link:

https://developers.arcgis.com/applications 

There is no redirect URL generated.

Seems to me there should be a link between the clientID and the map, but that seems not to be the case.

I have this working using your clientID and my private map.

Totally not clear to me...

0 Kudos
ErwinSoekianto
Esri Regular Contributor

You need to add that redirect URL in your "Application" in either ArcGIS Online or Developers.arcgis.com, they are the same thing, just a different interface. 

This specific redirect URL is added when you create a new application in ArcGIS Online and you need this redirect URL for when using the client ID in the OAuth page in a native application. It has nothing to do with the map, it is related to the client application that is using the Client ID to authenticate to ArcGIS Online using OAuth. 

0 Kudos
PHerk
by
New Contributor II

There is no redirect URL created when I add a new application, nor there is a default value. The field is empty, but I enter this URI: urn:ietf:wg:oauth:2.0:oob

That works so OK with me.

Thank you.

CraigGadaloff
New Contributor II

Hey @p van henk did you end up getting a worked example of this?

I can only find paragraphs of writing but no examples. Also in the dark here...

0 Kudos
PHerk
by
New Contributor II

Hi Craig. No success. Didn't find any working examples, and I spend searching and trying for many hours. But I am thankful Erwin gives a helping hand. Waiting for his sample. 

0 Kudos
PHerk
by
New Contributor II

Craig, look at Erwin's sample. Success.

0 Kudos
CraigGadaloff
New Contributor II

Great thanks Erwin and Piet. I have my map loaded.