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 Amazon Location Service SDK

If you need functionality in the AWS services used by the Amplify Geo category that isn't available, we provide an escape hatch so you can get a reference to that service.

Note: If you provisioned your Geo resources via Amplify CLI, then the IAM policy will be specifically scoped to only allow actions required by the library. Please adjust your authorization permissions accordingly for your escape hatch use-cases.

Learn more about consuming Kotlin clients from Java using either a blocking interface or an equivalent async interface based on futures here.

import android.util.Log;
import androidx.annotation.NonNull;
import com.amplifyframework.core.Amplify;
import com.amplifyframework.geo.location.AWSLocationGeoPlugin;
import aws.sdk.kotlin.services.location.LocationClient;
import aws.sdk.kotlin.services.location.model.ListMapsRequest;
import aws.sdk.kotlin.services.location.model.ListMapsResponse;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.CoroutineContext;
import kotlinx.coroutines.GlobalScope;
// Obtain reference to the plugin
AWSLocationGeoPlugin geoPlugin = (AWSLocationGeoPlugin)
Amplify.Geo.getPlugin("awsLocationGeoPlugin");
LocationClient locationClient = geoPlugin.getEscapeHatch();
// Send a new request to the Location Maps endpoint directly using the client
ListMapsRequest request = ListMapsRequest.Companion.invoke(requestBuilder -> Unit.INSTANCE);
locationClient.listMaps(request, new Continuation<ListMapsResponse>() {
@NonNull
@Override
public CoroutineContext getContext() {
return GlobalScope.INSTANCE.getCoroutineContext();
}
@Override
public void resumeWith(@NonNull Object resultOrException) {
Log.i("MyAmplifyApp", resultOrException.toString());
}
});
import android.util.Log
import aws.sdk.kotlin.services.location.LocationClient
import aws.sdk.kotlin.services.location.model.ListMapsRequest
import com.amplifyframework.core.Amplify
// Obtain reference to the Amazon Location Service client
val geoPlugin = Amplify.Geo.getPlugin("awsLocationGeoPlugin")
val locationClient = geoPlugin.escapeHatch as LocationClient
// Send a new request to the Location Maps endpoint directly using the client
val request = ListMapsRequest { }
val response = locationClient.listMaps(request)
Log.i("MyAmplifyApp", response.entries.toString())

Documentation Resources

Maps

Places

Device Tracking