Set up location-driven Geotriggers

View inQMLC++
View on GitHub
Sample viewer app

Create a notification every time a given location data source has entered and/or exited a set of features or graphics.

screenshot

Use case

Geotriggers can be used to notify users when they have entered or exited a geofence by monitoring a given set of features or graphics. They could be used to display contextual information to museum visitors about nearby exhibits, notify hikers when they have wandered off their desired trail, notify dispatchers when service workers arrive at a scene, or more.

How to use the sample

Observe a virtual walking tour of the Santa Barbara Botanic Garden. Information about the user's current Garden Section, as well as information about nearby points of interest within 10 meters will display or be removed from the UI when the user enters or exits the buffer of each feature.

How it works

  1. Create a GeotriggerFeed with a LocationDataSource class (in this case, a SimulatedLocationDataSource).
  2. Create a FeatureFenceParameters with a ServiceFeatureTable and a buffer distance at which to monitor each feature.
  3. Create a FenceGeotrigger with the geotrigger feed, a FenceRuleType, the fence parameters, an Arcade Expression, and a name for the specific geotrigger.
  4. Create a GeotriggerMonitor with the fence geotrigger and call GeotriggerMonitor::start() to begin listening for events that meet the FenceRuleType.
  5. When a GeotriggerMonitor::geotriggerNotification emits, capture the GeotriggerNotificationInfo.
  6. For more information about the feature that triggered the notification, cast the GeotriggerNotificationInfo to a FenceGeotriggerNotificationInfo and call FenceGeotriggerNotificationInfo::fenceGeoElement().
  7. Depending on the FenceGeotriggerNotificationInfo::fenceNotificationType() display or hide information on the UI from the GeoElement's attributes.

Relevant API

  • ArcadeExpression
  • FeatureFenceParameters
  • FenceGeotrigger
  • FenceGeotriggerNotificationInfo
  • FenceRuleType
  • GeoElement
  • Geotrigger
  • GeotriggerFeed
  • GeotriggerMonitor
  • GeotriggerNotificationInfo
  • ServiceFeatureTable
  • SimulatedLocationDataSource

About the data

This sample uses the Santa Barbara Botanic Garden Geotriggers Sample ArcGIS Online Web Map which includes a georeferenced map of the garden as well as select polygon and point features to denote garden sections and points of interest. Description text and attachment images in the feature layers were provided by the Santa Barbara Botanic Garden and more information can be found on the Garden Sections & Displays portion of their website. All assets are used with permission from the Santa Barbara Botanic Garden. For more information, visit the Santa Barbara Botanic Garden website.

Tags

alert, arcade, fence, geofence, geotrigger, location, navigation, notification, notify, routing, trigger

Sample Code

Geotriggers.qmlFeatureInfoPane.qmlGeotriggers.cppGeotriggers.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
// [WriteFile Name=Geotriggers, Category=Analysis]
// [Legal]
// Copyright 2021 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 QtQuick.Layouts 1.3
import Esri.Samples 1.0

Item {
    id: applicationWindowItem

    property var currentFeatureName: ""

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

    // Declare the C++ instance which creates the scene etc. and supply the view
    GeotriggersSample {
        id: sampleModel
        mapView: view
    }

    // The featureSelectButtonsColumn displays the current section as well as points of interest within 10 meters
    // Buttons are added and removed when a feature fence has been entered or exited.
    Control {
        id: featureSelectButtonsColumn
        anchors.right: parent.right
        padding: 10

        visible: !featureInfoPane.visible

        background: Rectangle {
            color: "white"
            border.color: "black"
        }

        contentItem: Column {
            id: column
            width: 200
            spacing: 10

            Text {
                anchors.horizontalCenter: parent.horizontalCenter
                horizontalAlignment: Text.AlignHCenter
                padding: 5
                text: "Current Garden Section"
                color: "#3B4E1E"
                font {
                    bold: true
                    pointSize: 20
                }
            }

            RoundButton {
                id: sectionButton
                width: parent.width - 10
                padding: 20

                Text {
                    id: buttonText
                    anchors.centerIn: parent
                    horizontalAlignment: Text.AlignHCenter
                    verticalAlignment: Text.AlignVCenter
                    width: parent.width - 5

                    text: sampleModel.currentSection
                    font {
                        bold: true
                        pointSize: 18
                    }
                    wrapMode: Text.WordWrap
                    color: "white"
                }

                background: Rectangle {
                    radius: sectionButton.radius
                    color: "#3B4E1E"
                }

                enabled: buttonText.text !== "N/A"

                onClicked: {
                    currentFeatureName = buttonText.text;
                    sampleModel.getFeatureInformation(currentFeatureName);
                    featureInfoPane.visible = true
                }
            }

            Rectangle {
                id: dividingLine
                anchors.horizontalCenter: parent.horizontalCenter
                width: parent.width - 20
                height: 2

                color: "black"

                visible: poiHeader.visible
            }

            Text {
                id: poiHeader
                anchors.horizontalCenter: parent.horizontalCenter
                horizontalAlignment: Text.AlignHCenter
                padding: 5

                text: "Points of Interest"
                font {
                    bold: true
                    pointSize: 16
                }
                color: "#AC901E"

                visible: sampleModel.poisInRange.length > 0
            }

            Repeater {
                model: sampleModel.poisInRange
                delegate: RoundButton {
                    id: poiButton
                    width: parent.width - 10
                    padding: 20

                    Text {
                        id: poiButtonText
                        anchors.centerIn: parent
                        horizontalAlignment: Text.AlignHCenter
                        width: parent.width - 5

                        text: modelData
                        wrapMode: Text.WordWrap
                        font.bold: true
                        color: "white"
                    }

                    background: Rectangle {
                        anchors.fill: parent
                        radius: sectionButton.radius
                        color: "#AC901E"
                    }

                    onClicked: {
                        currentFeatureName = poiButtonText.text;
                        sampleModel.getFeatureInformation(currentFeatureName);
                        featureInfoPane.visible = true
                    }
                }
            }
        }
    }

    // The FeatureInfoPane displays the name, description, and image retrieved from a fence feature.
    FeatureInfoPane {
        id: featureInfoPane

        featureName: currentFeatureName
        description: sampleModel.currentDescription
        imageSourceUrl: sampleModel.currentImageUrl
    }
}

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