The `getAvailableMaps` API fetches information for all maps that are available to be displayed.
This is useful if you would like to give your users a variety of map styles to choose from.
```java
Amplify.Geo.getAvailableMaps(
result -> {
for (final MapStyle style : result) {
Log.i("MyAmplifyApp", style.toString());
}
},
error -> Log.e("MyAmplifyApp", "Failed to get available maps.", error)
);
```
```kotlin
Amplify.Geo.getAvailableMaps(
{
for (mapStyle in it) {
Log.i("MyAmplifyApp", mapStyle.toString())
}
},
{ Log.e("MyAmplifyApp", "Failed to get available maps.", it) }
)
```
```kotlin
try {
val result = Amplify.Geo.getAvailableMaps()
for (mapStyle in result) {
Log.i("MyAmplifyApp", mapStyle.toString())
}
} catch (error: GeoException) {
Log.e("MyAmplifyApp", "Failed to get available maps.", error)
}
```
```java
RxAmplify.Geo.getAvailableMaps().subscribe(
result -> {
for (final MapStyle style : result) {
Log.i("MyAmplifyApp", style.toString());
}
},
error -> Log.e("MyAmplifyApp", "Failed to get available maps.", error)
);
```
You can set a different style to your map using `setStyle` method from the adapter:
With `MapLibreView`:
```java
// where mapStyle is a reference to the selected style from Amplify.Geo.getAvailableMaps
mapView.setStyle(mapStyle, style -> {
Log.i("MyAmplifyApp", "Finished loading " + mapStyle.getStyle());
});
```
With `AmplifyMapView`:
```java
// where mapStyle is a reference to the selected style from Amplify.Geo.getAvailableMaps
amplifyMapView.getMapView().setStyle(mapStyle, style -> {
Log.i("MyAmplifyApp", "Finished loading " + mapStyle.getStyle());
});
```
With `MapLibreView`:
```kotlin
// where mapStyle is a reference to the selected style from Amplify.Geo.getAvailableMaps
mapView.setStyle(mapStyle) { style ->
Log.i("MyAmplifyApp", "Finished loading ${mapStyle.style}.")
}
```
With `AmplifyMapView`:
```kotlin
// where mapStyle is a reference to the selected style from Amplify.Geo.getAvailableMaps
amplifyMapView.mapView.setStyle(mapStyle) { style ->
Log.i("MyAmplifyApp", "Finished loading ${mapStyle.style}.")
}
```