You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -3,7 +3,7 @@ title: 'Tutorial: Create a geofence and track devices on a Microsoft Azure Map'
3
3
description: Tutorial on how to set up a geofence. See how to track devices relative to the geofence by using the Azure Maps Spatial service
4
4
author: eriklindeman
5
5
ms.author: eriklind
6
-
ms.date: 09/14/2023
6
+
ms.date: 02/07/2024
7
7
ms.topic: tutorial
8
8
ms.service: azure-maps
9
9
services: azure-maps
@@ -21,11 +21,11 @@ Consider the following scenario:
21
21
Azure Maps provides services to support the tracking of equipment entering and exiting the construction area. In this tutorial, you will:
22
22
23
23
> [!div class="checklist"]
24
-
>
25
-
> * Upload [Geofencing GeoJSON data] that defines the construction site areas you want to monitor. You'll upload geofences as polygon coordinates to your Azure storage account, then use the [data registry] service to register that data with your Azure Maps account.
24
+
><!-- > * Upload [Geofencing GeoJSON data] that defines the construction site areas you want to monitor. You'll upload geofences as polygon coordinates to your Azure storage account, then use the [data registry] service to register that data with your Azure Maps account. --->
25
+
> * Upload [Geofencing GeoJSON data] that defines the construction site areas you want to monitor. You'll use the [Data Upload API]to upload geofences as polygon coordinates to your Azure Maps account.
26
26
> * Set up two [logic apps] that, when triggered, send email notifications to the construction site operations manager when equipment enters and exits the geofence area.
27
27
> * Use [Azure Event Grid] to subscribe to enter and exit events for your Azure Maps geofence. You set up two webhook event subscriptions that call the HTTP endpoints defined in your two logic apps. The logic apps then send the appropriate email notifications of equipment moving beyond or entering the geofence.
28
-
> * Use [Search Geofence Get API] to receive notifications when a piece of equipment exits and enters the geofence areas.
28
+
> * Use [Spatial Geofence Get API] to receive notifications when a piece of equipment exits and enters the geofence areas.
29
29
30
30
## Prerequisites
31
31
@@ -39,11 +39,47 @@ This tutorial uses the [Postman] application, but you can use a different API de
39
39
>
40
40
> In the URL examples, replace `{Your-Azure-Maps-Subscription-key}` with your Azure Maps subscription key.
41
41
42
+
## Create an Azure Maps account with a global region
43
+
44
+
The Geofence API async event requires the region property of your Azure Maps account be set to ***Global***. This setting isn't given as an option when creating an Azure Maps account in the Azure portal, however you do have several other options for creating a new Azure Maps account with the *global* region setting. This section lists the three methods that can be used to create an Azure Maps account with the region set to *global*.
45
+
46
+
> [!NOTE]
47
+
> The `location` property in both the ARM template and PowerShell `New-AzMapsAccount` command refer to the same property as the `Region` field in the Azure portal.
48
+
42
49
## Upload geofencing GeoJSON data
43
50
44
51
This tutorial demonstrates how to upload geofencing GeoJSON data that contains a `FeatureCollection`. The `FeatureCollection` contains two geofences that define polygonal areas within the construction site. The first geofence has no time expiration or restrictions. The second can only be queried against during business hours (9:00 AM-5:00 PM in the Pacific Time zone), and will no longer be valid after January 1, 2022. For more information on the GeoJSON format, see [Geofencing GeoJSON data].
45
52
46
-
Create the geofence JSON file using the following geofence data. You'll upload this file into your Azure storage account next.
53
+
>[!TIP]
54
+
>You can update your geofencing data at any time. For more information, see [Data Upload API].
55
+
To upload the geofencing GeoJSON data:
56
+
57
+
1. In the Postman app, select **New**.
58
+
59
+
2. In the **Create New** window, select **HTTP Request**.
60
+
61
+
3. Enter a **Request name** for the request, such as *POST GeoJSON Data Upload*.
62
+
63
+
4. Select the **POST** HTTP method.
64
+
65
+
5. Enter the following URL. The request should look like the following URL:
The `geojson` parameter in the URL path represents the data format of the data being uploaded.
72
+
73
+
> [!NOTE]
74
+
> Replace {geography} with your geographic scope. For more information, see [Azure Maps service geographic scope] and the [Spatial Geofence Get API].
75
+
76
+
6. Select the **Body** tab.
77
+
78
+
7. In the dropdown lists, select **raw** and **JSON**.
79
+
80
+
8. Copy the following GeoJSON data, and then paste it in the **Body** window:
81
+
82
+
<!--Create the geofence JSON file using the following geofence data. You'll upload this file into your Azure storage account next.-->
47
83
48
84
```JSON
49
85
{
@@ -131,10 +167,79 @@ Create the geofence JSON file using the following geofence data. You'll upload t
131
167
}
132
168
```
133
169
134
-
Follow the steps outlined in the [How to create data registry] article to upload the geofence JSON file into your Azure storage account and register it in your Azure Maps account.
170
+
<!--Follow the steps outlined in the [How to create data registry] article to upload the geofence JSON file into your Azure storage account and register it in your Azure Maps account.-->
171
+
172
+
9. Select **Send**.
173
+
174
+
10. In the response window, select the **Headers** tab.
175
+
176
+
11. Copy the value of the **Operation-Location** key, which is the `status URL`. The `status URL` is used to check the status of the GeoJSON data upload.
7. In the response window, select the **Headers** tab.
203
+
204
+
8. Copy the value of the **Resource-Location** key, which is the `resource location URL`. The `resource location URL` contains the unique identifier (`udid`) of the uploaded data. Save the `udid` to query the Get Geofence API in the last section of this tutorial.
205
+
206
+
### (Optional) Retrieve GeoJSON data metadata
207
+
208
+
You can retrieve metadata from the uploaded data. The metadata contains information like the resource location URL, creation date, updated date, size, and upload status.
209
+
210
+
To retrieve content metadata:
211
+
212
+
1. Select **New**.
213
+
214
+
2. In the **Create New** window, select **HTTP Request**.
215
+
216
+
3. Enter a **Request name** for the request, such as *GET Data Upload Metadata*.
217
+
218
+
4. Select the **GET** HTTP method.
219
+
220
+
5. Enter the `resource Location URL` you copied in [Check the GeoJSON data upload status]. The request should look like the following URL:
> Make sure to make a note of the unique identifier (`udid`) value, you will need it. The `udid` is how you reference the geofence you uploaded into your Azure storage account from your source code and HTTP requests.
242
+
-->
138
243
139
244
## Create workflows in Azure Logic Apps
140
245
@@ -248,15 +353,12 @@ Each of the following sections makes API requests by using the five different lo
248
353
249
354
4. Select the **GET** HTTP method.
250
355
251
-
5. Enter the following URL. The request should look like the following URL (replace `{udid}` with the `udid` you saved in the [Upload Geofencing GeoJSON data section]).
356
+
5. Enter the following URL. The request should look like the following URL (replace `{udid}` with the `udid` you saved in the [Upload Geofencing GeoJSON data] section).
> Replace {geography} with your geographic scope. For more information, see [Azure Maps service geographic scope] and the [Spatial Geofence Get API].
259
-
260
362
6. Select **Send**.
261
363
262
364
7. The response should like the following GeoJSON fragment:
@@ -287,7 +389,7 @@ Each of the following sections makes API requests by using the five different lo
287
389
}
288
390
```
289
391
290
-
In the preceding GeoJSON response, the negative distance from the main site geofence means that the equipment is inside the geofence. The positive distance from the subsite geofence means that the equipment is outside the subsite geofence. Because this is the first time this device has been located inside the main site geofence, the `isEventPublished` parameter is set to `true`. The Operations Manager receives an email notification that equipment has entered the geofence.
392
+
In the preceding GeoJSON response, the negative distance from the main site geofence means that the equipment is inside the geofence. The positive distance from the subsite geofence means that the equipment is outside the subsite geofence. Since it's the first time this device was located inside the main site geofence, the `isEventPublished` parameter is set to `true`. The Operations Manager receives an email notification that equipment entered the geofence.
291
393
292
394
### Location 2 (47.63800,-122.132531)
293
395
@@ -299,7 +401,7 @@ In the preceding GeoJSON response, the negative distance from the main site geof
299
401
300
402
4. Select the **GET** HTTP method.
301
403
302
-
5. Enter the following URL. The request should look like the following URL (replace `{udid}` with the `udid` you saved in the [Upload Geofencing GeoJSON data section]).
404
+
5. Enter the following URL. The request should look like the following URL (replace `{udid}` with the `udid` you saved in the [Upload Geofencing GeoJSON data] section).
@@ -335,7 +437,7 @@ In the preceding GeoJSON response, the negative distance from the main site geof
335
437
}
336
438
````
337
439
338
-
In the preceding GeoJSON response, the equipment has remained in the main site geofence and hasn't entered the subsite geofence. As a result, the `isEventPublished` parameter is set to `false`, and the Operations Manager doesn't receive any email notifications.
440
+
In the preceding GeoJSON response, the equipment remained in the main site geofence and didn't enter the subsite geofence. As a result, the `isEventPublished` parameter is set to `false`, and the Operations Manager doesn't receive any email notifications.
@@ -347,7 +449,7 @@ In the preceding GeoJSON response, the equipment has remained in the main site g
347
449
348
450
4. Select the **GET** HTTP method.
349
451
350
-
5. Enter the following URL. The request should look like the following URL (replace `{udid}` with the `udid` you saved in the [Upload Geofencing GeoJSON data section]).
452
+
5. Enter the following URL. The request should look like the following URL (replace `{udid}` with the `udid` you saved in the [Upload Geofencing GeoJSON data] section).
@@ -383,7 +485,7 @@ In the preceding GeoJSON response, the equipment has remained in the main site g
383
485
}
384
486
````
385
487
386
-
In the preceding GeoJSON response, the equipment has remained in the main site geofence, but has entered the subsite geofence. As a result, the `isEventPublished` parameter is set to `true`. The Operations Manager receives an email notification indicating that the equipment has entered a geofence.
488
+
In the preceding GeoJSON response, the equipment remained in the main site geofence, and entered the subsite geofence. As a result, the `isEventPublished` parameter is set to `true`. The Operations Manager receives an email notification indicating that the equipment entered a geofence.
387
489
388
490
>[!NOTE]
389
491
>If the equipment had moved into the subsite after business hours, no event would be published and the operations manager wouldn't receive any notifications.
@@ -398,7 +500,7 @@ In the preceding GeoJSON response, the equipment has remained in the main site g
398
500
399
501
4. Select the **GET** HTTP method.
400
502
401
-
5. Enter the following URL. The request should look like the following URL (replace `{udid}` with the `udid` you saved in the [Upload Geofencing GeoJSON data section]).
503
+
5. Enter the following URL. The request should look like the following URL (replace `{udid}` with the `udid` you saved in the [Upload Geofencing GeoJSON data] section).
@@ -428,7 +530,7 @@ In the preceding GeoJSON response, the equipment has remained in the main site g
428
530
}
429
531
````
430
532
431
-
In the preceding GeoJSON response, the equipment has remained in the main site geofence, but has exited the subsite geofence. Notice, however, that the `userTime` value is after the `expiredTime` as defined in the geofence data. As a result, the `isEventPublished` parameter is set to `false`, and the Operations Manager doesn't receive an email notification.
533
+
In the preceding GeoJSON response, the equipment remained in the main site geofence, but exited the subsite geofence. Notice, however, that the `userTime` value is after the `expiredTime` as defined in the geofence data. As a result, the `isEventPublished` parameter is set to `false`, and the Operations Manager doesn't receive an email notification.
432
534
433
535
### Location 5 (47.63799, -122.134505)
434
536
@@ -440,7 +542,7 @@ In the preceding GeoJSON response, the equipment has remained in the main site g
440
542
441
543
4. Select the **GET** HTTP method.
442
544
443
-
5. Enter the following URL. The request should look like the following URL (replace `{udid}` with the `udid` you saved in the [Upload Geofencing GeoJSON data section]).
545
+
5. Enter the following URL. The request should look like the following URL (replace `{udid}` with the `udid` you saved in the [Upload Geofencing GeoJSON data] section).
@@ -476,9 +578,9 @@ In the preceding GeoJSON response, the equipment has remained in the main site g
476
578
}
477
579
````
478
580
479
-
In the preceding GeoJSON response, the equipment has exited the main site geofence. As a result, the `isEventPublished` parameter is set to `true`, and the Operations Manager receives an email notification indicating that the equipment has exited a geofence.
581
+
In the preceding GeoJSON response, the equipment exited the main site geofence. As a result, the `isEventPublished` parameter is set to `true`, and the Operations Manager receives an email notification indicating that the equipment exited a geofence.
480
582
481
-
You can also [Send email notifications using Event Grid and Logic Apps]. For more information,see [Event handlers in Azure Event Grid].
583
+
You can also [Send email notifications using Event Grid and Logic Apps]. For more information,see [Event handlers in Azure Event Grid].
482
584
483
585
## Clean up resources
484
586
@@ -495,18 +597,17 @@ There are no resources that require cleanup.
0 commit comments