Set up location-driven Geotriggers

View inWPFUWPFormsiOSAndroid
View on GitHub

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

Image of Set up location-driven Geotriggers

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 class from a ServiceFeatureTable, a buffer distance at which to monitor each feature, an Arcade Expression, and a name for the specific geotrigger.
  3. Create a FenceGeotrigger with the geotrigger feed, a FenceRuleType, and the fence parameters.
  4. Create a GeotriggerMonitor with the fence geotrigger and call GeotriggerMonitor.StartAsync() to begin listening for events that meet the FenceRuleType.
  5. When a GeotriggerMonitor.Notification emits, capture the GeotriggerNotificationInfo.
  6. For more information about the feature that triggered the notification, cast the GeotriggerNotificationInfo to a FenceGeotriggerNotificationInfo and call FenceGeotriggerNotificationInfo..
  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

LocationDrivenGeotriggers.xamlLocationDrivenGeotriggers.xaml.cs
                                                         
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
<ContentPage x:Class="ArcGISRuntimeXamarin.Samples.LocationDrivenGeotriggers.LocationDrivenGeotriggers"
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
             xmlns:mapping="clr-namespace:Esri.ArcGISRuntime.Mapping;assembly=Esri.ArcGISRuntime"
             xmlns:resources="clr-namespace:Forms.Resources;assembly=ArcGISRuntime"
             xmlns:toolkit="clr-namespace:Esri.ArcGISRuntime.Toolkit.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Toolkit.Xamarin.Forms">
    <RelativeLayout>
        <esriUI:MapView x:Name="MyMapView"
                        BindingContext="{x:Reference Name=ResponsiveFormContainer}"
                        Style="{StaticResource MapWithFormStyle}" />
        <resources:ResponsiveFormContainer x:Name="ResponsiveFormContainer">
            <StackLayout>
                <Label x:Name="EventLabel" />
                <Button x:Name="SectionButton" Clicked="SectionButton_Clicked" />
                <Label x:Name="POILabel" />
                <Button x:Name="PlayPauseButton"
                        Pressed="PlayPauseButton_Pressed"
                        Text="Pause" />
            </StackLayout>
        </resources:ResponsiveFormContainer>
        <Frame x:Name="PopupPage"
               Padding="0"
               BackgroundColor="White"
               CornerRadius="0"
               IsVisible="False"
               RelativeLayout.HeightConstraint="{ConstraintExpression Type=Constant,
                                                                      Constant=335,
                                                                      Property=Height}"
               RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,
                                                                     Factor=.9,
                                                                     Property=Width}"
               RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,
                                                                 Factor=.05,
                                                                 Property=Width}"
               RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,
                                                                 Factor=.05,
                                                                 Property=Height}">
            <StackLayout>
                <Label x:Name="FeatureName"
                       Margin="5"
                       HeightRequest="15" />
                <Image x:Name="FeatureImage"
                       Margin="5"
                       HeightRequest="150" />
                <ScrollView Margin="5" HeightRequest="100">
                    <Label x:Name="FeatureDescription" LineBreakMode="WordWrap" />
                </ScrollView>
                <Button x:Name="PopupCloseButton"
                        Margin="5"
                        Clicked="PopupCloseButton_Clicked"
                        HeightRequest="30"
                        Text="Close" />
            </StackLayout>
        </Frame>
    </RelativeLayout>
</ContentPage>

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