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
@@ -27,76 +27,136 @@ export function getStaticProps(context) {
27
27
};
28
28
}
29
29
30
-
Amplify provides APIs and map UI components for maps and location search for your web apps.You can add maps and location search functionality to your app in just a few lines of code. The following is an example utilizing the [AWS Cloud Development Kit (AWS CDK)](https://docs.aws.amazon.com/cdk/latest/guide/home.html) to create a Geo resource powered by [Amazon Location Services](https://aws.amazon.com/location/). But do note there are no official hand-written (L2) constructs for this service yet.
30
+
In this guide, you will learn how to set up Geo in your Amplify app. You will set up your backend resources, manage their access, and integrate geo maps, place indices, and geofence collections within your application.
31
+
32
+
If you have not yet created an Amplift app, visit the [quickstart guide](/[platform]/start/quickstart/).
33
+
34
+
Amazon Location Services now offers independent APIs and UI components for maps and location search for your web apps, eliminating the need to provision these resources. You can add maps, location search (place index), and geofencing functionality to your app in just a few lines of code. Learn more about these resources [here](https://docs.aws.amazon.com/location/latest/developerguide/what-is.html).
35
+
36
+
## Building your Geo backend
37
+
38
+
First, create a file `amplify/geo/resource.ts` within your Amplify app. This file will be the location to configure your Geo backend resources. This entails managing access to maps and location search and provisioning geofence collections. For example, you can instantiate a geofence collection, place index, or a map resource by using the `defineMap`, `definePlace`, or `defineCollection` functions and providing a `name` for these resources.
39
+
40
+
```ts title="amplify/geo/resource.ts"
41
+
import {
42
+
defineMap,
43
+
defineCollection,
44
+
definePlace,
45
+
} from'@aws-amplify/backend-geo';
46
+
47
+
exportconst map =defineMap({
48
+
name: 'amplifyMap',
49
+
});
50
+
51
+
exportconst place =definePlace({
52
+
name: 'amplifyPlaceIndex',
53
+
});
54
+
55
+
exportconst collection =defineCollection({
56
+
name: 'amplifyCollection'
57
+
});
58
+
```
59
+
60
+
Now, import these resource definitions within your `amplify/backend.ts` file that contains your backend definition. Add these Geo resources to `defineBackend`.
This command will deploy a Geofence Collection to your cloud sandbox and generate access policies to integrate the map and location search resources with your Amplify app.
111
+
112
+
## Define resource access permissions
113
+
114
+
All maps, place indices, and geofence collections requested by Amplify Geo are inaccessible by users or other resources by default. Access to these resources must be explicitly granted within the `access` callback of the `defineMap`, `definePlace`, and `defineCollection` functions. Refer to the [access actions](#resource-access-actions) for all resource types to pick appropriate actions for your API access definitions.
115
+
116
+
The following example shows you how you can set up your map and collection access structure for authorized and guest users.
117
+
118
+
1. Guests only have access to read into and list geofence collections.
119
+
2. Authenticated users can create, read, update, and delete geofence collections while also being able to access the static ma managed by AWS.
120
+
121
+
```ts title="amplify/geo/resource.ts"
122
+
exportconst map =defineMap({
123
+
name: 'amplifyMap',
124
+
access: (allow) => [
125
+
allow.authenticated.to(['get'])
61
126
],
62
127
});
63
128
64
-
// create an IAM policy to allow interacting with geo resource
// patch the map resource to the expected output configuration
85
-
backend.addOutput({
86
-
geo: {
87
-
aws_region: geoStack.region,
88
-
maps: {
89
-
items: {
90
-
[map.mapName]: {
91
-
style: "VectorEsriNavigation",
92
-
},
93
-
},
94
-
default: map.mapName,
95
-
},
96
-
},
142
+
You can define these additional geofence collections by reusing the `defineCollection` function while providing a unique `name` to identify the collection. You can configure specific access permissions to these collections by adding them to the API with the unique `name`.
143
+
144
+
<Calloutinfo>
145
+
146
+
**Note**: If numerous geofence collections are defined, then one of them must be marked as default using the `isDefault` flag.
The pricing plan for the Map example is set to `RequestBasedUsage`.
425
511
We advice you to go through the [location service pricing](https://aws.amazon.com/location/pricing/) along with the [location service terms](https://aws.amazon.com/service-terms/) (_82.5 section_) to learn more about the pricing plan.
0 commit comments