Show popup

View inQMLC++
View on GitHub
Sample viewer app

Show predefined popups from a web map.

screenshot

Use case

Many web maps contain predefined popups which are used to display the attributes associated with each feature layer in the map, such as hiking trails, land values, or unemployment rates. You can display text, attachments, images, charts, and web links. Rather than creating new popups to display information, you can easily access and display the predefined popups.

How to use the sample

Tap on the features to prompt a popup that displays information about the feature.

How it works

  1. Create and load a Map using a URL.
  2. Set the map to a MapView and connect to the MapQuickView::mouseClicked signal.
  3. Use GeoView::identifyLayer(layer, x, y, tolerance, allowPopupsOnly) to identify the top-most feature.
  4. Create a PopupManager for each of the result's Popups and append them to a list.
  5. Assign the list of popup managers to the PopupStackView.popupManagers property.
  6. Display the popup stack view.

Relevant API

  • IdentifyLayerResult
  • Map
  • PopupManager
  • PopupStackView

About the data

This sample uses a feature layer that displays reported incidents in San Francisco.

Additional information

In order to use the PopupManager with a QML UI, the PopupManager, PopupAttachmentManager, PopupAttachmentListModel, and PopupAttributeListModel classes must be registered as QML Types. For more information visit our developer site.

Tags

feature, feature layer, popup, web map

Sample Code

ShowPopup.qmlShowPopup.cppShowPopup.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
// [WriteFile Name=ShowPopup, Category=DisplayInformation]
// [Legal]
// Copyright 2020 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

Item {

    // add a mapView component
    MapView {
        id: view
        anchors.fill: parent
    }

    PopupStackView {
        id: popupStackView
        anchors {
            top: parent.top
            bottom: parent.bottom
            right: parent.right
        }
        popupManagers: model.popupManagers
        visible: false

        onVisibleChanged: {
            if (!visible)
                model.clearSelection();
        }
    }

    // Declare the C++ instance which creates the scene etc. and supply the view
    ShowPopupSample {
        id: model
        mapView: view

        onPopupManagersChanged: popupStackView.visible = true
    }

    BusyIndicator {
        anchors.centerIn: parent
        running: model.taskRunning
    }
}

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