Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Apr 29, 2024

Use existing Amazon Location resources

Amplify Android v1 is deprecated as of June 1st, 2024. No new features or bug fixes will be added. Dependencies may become outdated and potentially introduce compatibility issues.

Please use the latest version (v2) of Amplify Library for Android to get started. Refer to the upgrade guide for instructions on upgrading your application to the latest version.

Amplify libraries should be used for all new cloud connected applications. If you are currently using the AWS Mobile SDK for Android, you can access the documentation here.

You can also use Amplify Geo with your existing Amazon Location Service resources if you'd like, there's just some manual setup that you need to do.

Authorization permissions

To use your existing Amazon Location Service resources, i.e. maps and place indices, with Amplify Geo, you need to ensure your role has the right authorization permissions through Cognito. If you set up your Cognito resources in any way other than the Amplify CLI or Amplify Studio, the roles will need to be given permission to access the map and place indices.

Note: Here is a guide on Creating an Amazon Cognito identity pool for use with Amazon Location Service

There are two roles created by Cognito: an Auth_Role that grants signed-in-user-level access and an Unauth_Role that allows unauthenticated access to resources. Attach the following policies for the appropriate resources and roles (Auth and/or Unauth). Replace {region}, {account-id}, and {enter Map/PlaceIndex name} with the correct items. Note that certain actions cannot be performed with unauthenticated access. The list of actions allowed for the Unauth role is in the Granting access to Amazon Location Service guide.

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "GetTiles",
"Effect": "Allow",
"Action": [
"geo:GetMapTile",
"geo:GetMapSprites",
"geo:GetMapGlyphs",
"geo:GetMapStyleDescriptor"
],
"Resource": "arn:aws:geo:{region}:{account-id}:map/{enter Map name}"
},
{
"Sid": "Search",
"Effect": "Allow",
"Action": [
"geo:SearchPlaceIndexForPosition",
"geo:SearchPlaceIndexForText"
],
"Resource": "arn:aws:geo:{region}:{account-id}:place-index/{enter PlaceIndex name}"
}
]
}

In your app configuration

Amplify Geo is dependent on your Amplify Auth category. If it is not already configured, then you will have to manually configure it as well. In order to manually configure Amplify Geo category, you must edit amplifyconfiguration.json in your project's src/main/res/raw directory with your information from existing Amazon Cognito and Amazon Location Service resources.

{
"UserAgent": "aws-amplify-cli/2.0",
"Version": "1.0",
"geo": {
"plugins": {
"awsLocationGeoPlugin": {
"region": <YOUR_REGION>,
"maps": {
"items": {
<YOUR_MAP_NAME>: {
"style": <YOUR_MAP_STYLE>
}
},
"default": <DEFAULT_MAP_NAME>
},
"searchIndices": {
"items": [
<YOUR_INDEX_NAME>
],
"default": <DEFAULT_INDEX_NAME>
}
}
}
},
"auth": {
"plugins": {
"awsCognitoAuthPlugin": {
"UserAgent": "aws-amplify-cli/0.1.0",
"Version": "0.1.0",
"IdentityManager": {
"Default": {}
},
"CredentialsProvider": {
"CognitoIdentity": {
"Default": {
"PoolId": <YOUR_IDENTITY_POOL_ID>,
"Region": <YOUR_REGION>
}
}
}
}
}
}
}

Now you can proceed to displaying a map or adding location search to your app.