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.
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 pluginAWSLocationGeoPlugin geoPlugin = (AWSLocationGeoPlugin) Amplify.Geo.getPlugin("awsLocationGeoPlugin");LocationClient locationClient = geoPlugin.getEscapeHatch();
// Send a new request to the Location Maps endpoint directly using the clientListMapsRequest 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.Logimport aws.sdk.kotlin.services.location.LocationClientimport aws.sdk.kotlin.services.location.model.ListMapsRequestimport com.amplifyframework.core.Amplify
// Obtain reference to the Amazon Location Service clientval geoPlugin = Amplify.Geo.getPlugin("awsLocationGeoPlugin")val locationClient = geoPlugin.escapeHatch as LocationClient
// Send a new request to the Location Maps endpoint directly using the clientval request = ListMapsRequest { }val response = locationClient.listMaps(request)Log.i("MyAmplifyApp", response.entries.toString())
Documentation Resources
Maps
Places
Device Tracking