Newer Version Available
GeofencingService Example
Here’s a basic example of a Lightning web component that uses a device’s biometrics
capabilities to verify device ownership.
Here’s a basic example of a Lightning web component that uses GeofencingService to monitor and determine when a user arrives or departs a geographic region.
1<template>
2 <lightning-card title="Geofencing Service" icon-name="custom:custom14">
3 <div class="slds-var-m-around_medium">
4 <p><lightning-formatted-text value={geofencingResults}></lightning-formatted-text></p>
5 <div class="slds-var-m-around_medium">
6 <p>Create an entry and exit geofence at the Salesforce Tower:</p>
7 <lightning-button variant="brand" label="Add Geofences"
8 title="Add Geofences to SF Tower"
9 onclick={addGeofence}
10 class="slds-var-m-around_x-small"
11 disabled={geofencingServiceDisabled}>
12 </lightning-button>
13 </div>
14 <div class="slds-var-m-around_medium">
15 <p><lightning-formatted-text value={geofencingAddedResults}></lightning-formatted-text></p>
16 </div>
17 </div>
18 <div class="slds-var-m-around_medium">
19 <div class="slds-var-m-around_medium">
20 <p>Remove all active geofences:</p>
21 <lightning-button variant="brand" label="Remove All Geofences"
22 title="Remove all geofences"
23 onclick={removeGeofences}
24 class="slds-var-m-around_x-small"
25 disabled={geofencingServiceDisabled}>
26 </lightning-button>
27 </div>
28 <div class="slds-var-m-around_medium">
29 <p><lightning-formatted-text value={removeGeofencesResults}></lightning-formatted-text></p>
30 </div>
31 </div>
32 <div class="slds-var-m-around_medium">
33 <div class="slds-var-m-around_medium">
34 <p>Get list of all active geofences:</p>
35 <lightning-button variant="brand" label="Get Active Geofences"
36 title="Get active geofences"
37 onclick={getActiveGeofences}
38 class="slds-var-m-around_x-small"
39 disabled={geofencingServiceDisabled}>
40 </lightning-button>
41 </div>
42 <div class="slds-var-m-around_medium">
43 <p><lightning-formatted-text value={activeGeofencesResults}></lightning-formatted-text></p>
44 <ul class="slds-var-m-around_medium">
45 <template for:each={activeGeofences} for:item="geofence">
46 <li key={geofence}>{geofence}</li>
47 </template>
48 </ul>
49 </div>
50 </div>
51 </lightning-card>
52</template>