Skip to content

Commit f25a462

Browse files
Merge pull request SharePoint#7781 from SidGulatiMsft/geolocationDocumentation
Documentation for geolocation action in Adaptive Card Extension
2 parents 3173fe6 + b1e65ed commit f25a462

11 files changed

+527
-0
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
---
2+
title: Location capabilities in Adaptive Card Extension
3+
description: Geolocation is a new action that the SharePoint Adaptive Card Extension framework supports, which enables third party developers to come up with their ___location specific scenarios.
4+
ms.date: 04/06/2022
5+
ms.prod: sharepoint
6+
ms.localizationpriority: high
7+
---
8+
# Location capabilities in Adaptive Card Extension
9+
10+
> [!NOTE]
11+
> The geolocation capability in Adaptive Card Extension will be available in SPFx v1.15.
12+
>
13+
> So make sure that you have installed it before proceeding further.
14+
>
15+
> For more information on installing the SPFx v1.15 Preview, see [SharePoint Framework v1.15 release notes](../../../../release-1.15.md).
16+
>
17+
> This tutorial also assumes that you have already built a SharePoint Adaptive Card Extension.
18+
>
19+
> To learn how to create your first SharePoint Adaptive Card Extension, try out [this tutorial](../../../get-started/build-first-sharepoint-adaptive-card-extension.md).
20+
21+
### New action types for geolocation
22+
23+
There are 2 Location actions:
24+
25+
1. Get Location
26+
1. Show Location
27+
28+
### Get Location:
29+
30+
Gives user’s current device ___location or opens a ___location picker and returns the ___location chosen by the user. In the browser it uses Bing Maps as the mapping interface.
31+
32+
The ACE action for Get Location is: `VivaAction.GetLocation`.
33+
34+
It takes an optional boolean parameter: `ChooseLocationOnMap`.
35+
36+
If the property `ChooseLocationOnMap` is set to `true`, then the action will open a map, and user will get to choose a ___location on the map, otherwise, it will fetch user's current device ___location.
37+
38+
### Show Location:
39+
40+
With this action, a map shows up on the screen on which you can either show the user's current ___location on the map or you can show your specified coordinates on the map.
41+
42+
The ACE action for Show Location is: `VivaAction.ShowLocation`.
43+
44+
It takes an optional ___location parameter: `locationCoordinates`.
45+
46+
To show a specific ___location, you should pass the ___location coordinates (latitude and longitude) via the `locationCoordinates` parameter.
47+
48+
The `locationCoordinates` object consists of the following properties:
49+
50+
```typescript
51+
{
52+
/**
53+
* Latitude of the ___location.
54+
*/
55+
latitude: number;
56+
57+
/**
58+
* Longitude of the ___location.
59+
*/
60+
longitude: number;
61+
62+
/**
63+
* Timestamp (optional).
64+
*/
65+
timestamp?: number;
66+
67+
/**
68+
* Accuracy of the ___location (optional).
69+
*/
70+
accuracy?: number;
71+
}
72+
```
73+
74+
### Tutorial and Examples
75+
76+
You can take a look at [this tutorial](./GeolocationTutorial.md) which goes over the step by step details of how you could create a card with geolocation actions.
77+
78+
The following examples describe the geolocation action and their purpose.
79+
80+
1. **Get user's current ___location**
81+
82+
In your template JSON, introduce the following action:
83+
84+
```json
85+
"actions": [{
86+
type: 'VivaAction.GetLocation',
87+
id: 'Get Location'
88+
}]
89+
```
90+
91+
When this action gets invoked, user's current geolocation is fetched and is passed to the Third Party Developer via the onAction callback.
92+
93+
> [!NOTE]
94+
> In this case, map doesn't show up.
95+
96+
1. **Select ___location from a map**
97+
98+
In your template JSON, introduce the following action:
99+
100+
```json
101+
"actions": [{
102+
type: 'VivaAction.GetLocation',
103+
id: 'Get Location',
104+
parameters: {chooseLocationOnMap: true}
105+
}]
106+
```
107+
108+
When this action gets invoked, a map pointing to user's current ___location opens up and the user gets to select and share the ___location of their choice. The selected ___location's coordinates are passed to the Third Party Developer via the onAction callback.
109+
110+
1. **Display user's current ___location**
111+
112+
In your template JSON, introduce the following action:
113+
114+
```json
115+
"actions": [{
116+
type: 'VivaAction.ShowLocation',
117+
id: 'Show Location'
118+
}]
119+
```
120+
121+
When this action gets invoked, a map opens up and the user's current ___location coordinates are shown on it.
122+
123+
1. **Display a specified ___location**
124+
125+
In your template JSON, introduce the following action:
126+
127+
```json
128+
"actions": [{
129+
type: 'VivaAction.ShowLocation',
130+
id: 'Show Location',
131+
parameters: {
132+
locationCoordinates: {
133+
latitude: 28.6132039578389,
134+
longitude: 77.229488240066
135+
}
136+
}
137+
}]
138+
```
139+
140+
When this action gets invoked, a map opens up and it shows the ___location coordinates specified in the action.
141+
142+
### Access geolocation actions via card-designer card's property pane
143+
144+
If you don't want to write code, but still wish to see how the geolocation actions work, then you can explore [this tutorial](./GeolocationPropertyPane.md) which lets you create cards with geolocation actions via property pane.
145+
146+
> [!NOTE]
147+
> Theses geolocation actions can be added on the card view or the buttons of the card view or inside the quick view.
148+
149+
### Permission and error codes
150+
151+
For the ___location APIs to work, the user has to grant the permission to access device's ___location.
152+
153+
154+
Error Code | Error Description
155+
----------------- | -----------------
156+
PermissionDenied | User has denied the permission to access ___location
157+
InternalError | An unexpected error happened while invoking the ___location APIs
158+
HostNotSupported | The ___location action is being used in an unsupported environment
159+
160+
161+
### Callbacks for Card Developers
162+
163+
When the action `VivaAction.GetLocation` is invoked, we pass the fetched ___location coordinates via the onAction callback.
164+
165+
> [!NOTE]
166+
> onAction callback is not invoked for `VivaAction.ShowLocation`.
167+
168+
For actions: `VivaAction.GetLocation` and `VivaAction.ShowLocation`, if the user lands into an error state, then an onError callback will get invoked, to which we pass the action name and the error code.
169+
170+
### Availability of geolocation actions
171+
172+
> [!NOTE]
173+
> These new actions are **only available in the browser** currently. Viva Connections desktop and Viva Connections mobile support will be enabled later.
174+
After General Availability the support matrix for actions will look like:
175+
176+
Action | Viva Connection Desktop | Viva Connections Mobile | Browser
177+
------------- | ------------- | ------------- | -------------
178+
Get Location | Not Supported | Supported | Supported
179+
Show Location | Not Supported | Supported | Supported
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: Explore Geolocation capability via property pane of card-desinger card in Adaptive Card Extension
3+
description: Geolocation is a new action that the SharePoint Adaptive Card Extension framework supports, and in this tutorial we see how we can explore this capability via the property pane of the card-designer card.
4+
ms.date: 04/06/2022
5+
ms.prod: sharepoint
6+
ms.localizationpriority: high
7+
---
8+
9+
# Explore Geolocation capability via property pane of card-desinger card in Adaptive Card Extension
10+
11+
In this tutorial we will see how we can use the card-designer card's property pane to explore geolocation actions.
12+
13+
We will:
14+
15+
- Update the card strings
16+
- Introduce geolocation actions on the Card View, Primary button and Secondary button
17+
18+
First, figure out the ___domain to the URL of your SharePoint tenant and site you want to use for testing and access the `workbench.aspx` page. For example: `https://contoso.sharepoint.com/sites/devsite/_layouts/workbench.aspx`.
19+
20+
Here, click on the '+' icon in the middle of the page, and add the `card-designer` card on the canvas.
21+
22+
Next, click the pencil icon adjacent to this card to open the property pane.
23+
24+
### Update the card strings
25+
26+
Here, first set the `card size` to `Large`.
27+
28+
To provide descriptive labels, change `Title` to `GeoLocation`, `Heading` to `GeoLocation Demo` and `description` to `Demo GeoLocation Actions`.
29+
30+
![Adding strings in the property pane of card designer card](../../../../../../docs/images/viva-extensibility/geolocation/geoloactionPropertyPaneStrings.png)
31+
32+
### Adding action on Card View
33+
34+
Under `Actions`, click the drop-down menu of `card action` and select `Select ___location from a map` option.
35+
36+
![Set the on-click action to "Select ___location from a map" from the drop-down menu of card-view](../../../../../../docs/images/viva-extensibility/geolocation/geoloactionPropertyPaneCardAction.png)
37+
38+
### Adding action on Primary button
39+
40+
Next, for the `Primary Button`, set the `Title` to `My Location` and from its action drop-down menu, select `Display a specified or current ___location`.
41+
42+
![Set the on-click action to "Display a specified or current ___location" from the drop-down menu for the primary button](../../../../../../docs/images/viva-extensibility/geolocation/geoloactionPropertyPanePrimaryButtonAction.png)
43+
44+
### Adding action on Secondary button
45+
46+
Finally, for the `Secondary Button`, set the `Title` to `Custom Location` and from its action drop-down menu, select `Display a specified or current ___location`.
47+
48+
Next, turn on the `Display a specified ___location` toggle button.
49+
50+
This will bring up two text boxes for ___location coordinates.
51+
52+
Here you may provide any ___location coordinates of your choice.
53+
54+
For our example, we are putting in `27.98884062493244` as the value for the text-box labeled `latitude` and `86.9249751` for the text-box labeled `longitude`. These are the coordinates of Mount Everest.
55+
56+
![Set the on-click action to "Display a specified or current ___location" from the drop-down menu for the secondary button and pass coordinates of your choice in the respective ___location text-boxes](../../../../../../docs/images/viva-extensibility/geolocation/geoloactionPropertyPaneSecondaryButtonAction.png)
57+
58+
### Try the geolocation actions
59+
60+
Now close the property pane and click `Preview` from the top right hand corner of the page:
61+
62+
- Click on the card itself to select a ___location from the map
63+
- Clicking on `My ___location` will open a map showing your current ___location
64+
- Clicking on `Show custom ___location` will open a map showing your custom ___location (Mount Everest)
65+
66+
You can now check out the three geolocation actions that you introduced via the property pane.
67+
68+
![Card-Designer card with geolocation actions configured](../../../../../../docs/images/viva-extensibility/geolocation/geoloactionPropertyPaneCardGenerated.png)
69+
70+
> [!NOTE]
71+
> This property-pane experience doesn't allow you to introduce onAction callback, and hence the action `Select ___location from a map` is actually a no-op.

0 commit comments

Comments
 (0)