Show organization basemaps

View inQMLC++
View on GitHub
Sample viewer app

Connect to Portal to give users access to their organization's basemaps.

screenshot

Use case

Organizational basemaps are a Portal feature allowing organizations to specify basemaps for use throughout the organization. Customers expect that they will have access to their organization's standard basemap set when they connect to a Portal. Organizational basemaps are useful when certain basemaps are particularly relevant to the organization, or if the organization wants to make premium basemap content available to their workers.

How to use the sample

You'll be prompted to load a portal anonymously or with a log-in. After you sign in, you'll see thumbnails for these basemaps shown in a picker. Select a basemap to use it in the map.

How it works

  1. The user is prompted to load a portal anonymously or with a log-in.
  2. A Portal is then loaded - if the user chose to log-in in step 1, this uses a Credential of type OAuth.
  3. When the app starts, the portal is loaded and if required, the AuthenticationManager issues a challenge for the supplied credential type.
  4. The user is presented with an AuthenticationView which allows them to log-in.
  5. After a successful load, get the list of basemaps: portal::fetchBasemaps()

Relevant API

  • Portal
  • Portal::fetchBasemaps

Additional information

See Customize basemaps in the Portal for ArcGIS documentation to learn about customizing the organization's basemap list in a portal.

Tags

basemap, integration, organization, portal

Sample Code

ShowOrgBasemaps.qmlShowOrgBasemaps.cppShowOrgBasemaps.h
                                                                                                                                                                                                                                     
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
// [WriteFile Name=ShowOrgBasemaps, Category=CloudAndPortal]
// [Legal]
// Copyright 2016 Esri.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [Legal]

import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.Samples 1.0
import Esri.ArcGISRuntime.Toolkit 100.12

ShowOrgBasemapsSample {
    width: 800
    height: 600
    clip: true

    onPortalLoadedChanged: { gridFadeIn.running = true; }

    BusyIndicator {
        anchors.centerIn: parent
        running: !mapView.visible && !portalLoaded & !anonymousLogIn.visible
    }

    Text {
        id: titleLabel
        anchors {
            top: parent.top;
            left: parent.left;
            right: parent.right;
            margins: 10
        }
        font.pointSize: 14
        font.bold: true
        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignTop
        text: anonymousLogIn.visible ? "Load Portal" :
                                       (basemapsGrid.count > 0 ? orgName + " Basemaps" : "Loading Organization Basemaps...")
        wrapMode: Text.Wrap
        elide: Text.ElideRight
    }

    GridView {
        id: basemapsGrid
        anchors {
            top: titleLabel.bottom;
            bottom: parent.bottom;
            left: parent.left;
            right: parent.right
        }
        visible: portalLoaded
        cellWidth: 128;
        cellHeight: 128
        opacity: 0
        focus: true
        clip: true
        model: basemaps

        delegate: Rectangle {
            anchors.margins: 5
            width: basemapsGrid.cellWidth
            height: width
            border {width: 2; color: index === basemapsGrid.currentIndex ? "blue" : "lightgrey"}
            color: index === basemapsGrid.currentIndex ? "yellow" : "white"
            radius: 2
            clip: true

            //! [BasemapListModel example QML delegate]
            Image {
                id: basemapImg
                anchors {
                    bottom: basemapLabel.top;
                    horizontalCenter: parent.horizontalCenter
                }
                height: parent.height - ( basemapLabel.height * 2 );
                source: thumbnailUrl // use the thumbnailUrl role of the model
                width: height
                fillMode: Image.PreserveAspectCrop
            }

            Text {
                id: basemapLabel
                anchors {
                    bottom: parent.bottom;
                    left: parent.left;
                    right: parent.right
                }
                height: 16
                z: 100
                wrapMode: Text.Wrap
                horizontalAlignment: Text.AlignHCenter
                elide: Text.ElideRight
                text: title // use the title role of the model
                font.pointSize: 8
                font.bold: index === basemapsGrid.currentIndex
            }
            //! [BasemapListModel example QML delegate]

            MouseArea {
                enabled: !mapView.visible && portalLoaded
                anchors.fill: parent

                onClicked: {
                    if (!enabled)
                        return;

                    basemapsGrid.currentIndex = index;
                }
                onDoubleClicked: {
                    if (!enabled)
                        return;

                    selectedAnimation.running = true;
                    titleLabel.text = title;
                    loadSelectedBasemap(index);
                    gridFadeOut.running = true;
                }
            }

            SequentialAnimation on opacity {
                id: selectedAnimation
                running: false
                loops: 4
                PropertyAnimation { to: 0; duration: 60 }
                PropertyAnimation { to: 1; duration: 60 }
            }
        }

        OpacityAnimator on opacity {
            id: gridFadeIn
            from: 0;
            to: 1;
            duration: 2000
            running: false
        }

        OpacityAnimator on opacity {
            id: gridFadeOut
            from: 1;
            to: 0;
            duration: 2000
            running: false
        }
    }

    MapView {
        id: mapView
        objectName: "mapView"
        anchors {
            top: titleLabel.bottom;
            bottom: parent.bottom;
            left: parent.left;
            right: parent.right
        }
        visible: false
    }

    Button {
        id: backButton
        anchors {
            top: mapView.top
            right: mapView.right
            margins: 16
        }
        visible: mapView.visible
        text: "Back"
        icon.source: "qrc:/Samples/CloudAndPortal/ShowOrgBasemaps/ic_menu_back_dark.png"

        opacity: hovered ? 1 : 0.5

        onClicked: {
            titleLabel.text = "Basemaps";
            mapView.visible = false;
            basemapsGrid.enabled = true;
            gridFadeIn.running = true;
        }
    }

    Button {
        id: anonymousLogIn
        anchors {
            margins: 16
            horizontalCenter: parent.horizontalCenter
            top: titleLabel.bottom
        }
        text: "Anonymous"
        icon.source: "qrc:/Samples/CloudAndPortal/ShowOrgBasemaps/ic_menu_help_dark.png"

        onClicked: {
            load(true);
            anonymousLogIn.visible = false;
            userLogIn.visible = false;
        }
    }

    Button {
        id: userLogIn
        anchors {
            margins: 16
            horizontalCenter: anonymousLogIn.horizontalCenter
            top: anonymousLogIn.bottom
        }
        width: anonymousLogIn.width
        text: "Sign-in"
        icon.source: "qrc:/Samples/CloudAndPortal/ShowOrgBasemaps/ic_menu_account_dark.png"

        onClicked: {
            load(false);
            anonymousLogIn.visible = false;
            userLogIn.visible = false;
        }
    }

    /*
    // Uncomment this section when running as standalone application
    AuthenticationView {
        anchors.fill: parent
    }*/

}

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