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.
1import android.util.Log;2
3import androidx.annotation.NonNull;4
5import com.amplifyframework.core.Amplify;6import com.amplifyframework.geo.location.AWSLocationGeoPlugin;7
8import aws.sdk.kotlin.services.location.LocationClient;9import aws.sdk.kotlin.services.location.model.ListMapsRequest;10import aws.sdk.kotlin.services.location.model.ListMapsResponse;11import kotlin.Unit;12import kotlin.coroutines.Continuation;13import kotlin.coroutines.CoroutineContext;14import kotlinx.coroutines.GlobalScope;
1// Obtain reference to the plugin2AWSLocationGeoPlugin geoPlugin = (AWSLocationGeoPlugin)3 Amplify.Geo.getPlugin("awsLocationGeoPlugin");4LocationClient locationClient = geoPlugin.getEscapeHatch();5
6// Send a new request to the Location Maps endpoint directly using the client7ListMapsRequest request = ListMapsRequest.Companion.invoke(requestBuilder -> Unit.INSTANCE);8locationClient.listMaps(request, new Continuation<ListMapsResponse>() {9 @NonNull10 @Override11 public CoroutineContext getContext() {12 return GlobalScope.INSTANCE.getCoroutineContext();13 }14
15 @Override16 public void resumeWith(@NonNull Object resultOrException) {17 Log.i("MyAmplifyApp", resultOrException.toString());18 }19});
1import android.util.Log2import aws.sdk.kotlin.services.location.LocationClient3import aws.sdk.kotlin.services.location.model.ListMapsRequest4import com.amplifyframework.core.Amplify
1// Obtain reference to the Amazon Location Service client2val geoPlugin = Amplify.Geo.getPlugin("awsLocationGeoPlugin")3val locationClient = geoPlugin.escapeHatch as LocationClient4
5// Send a new request to the Location Maps endpoint directly using the client6val request = ListMapsRequest { }7val response = locationClient.listMaps(request)8Log.i("MyAmplifyApp", response.entries.toString())
Documentation Resources
Maps
Places
Device Tracking