Skip to content

Commit

Permalink
chore: update README with instructions to add maps-compose-utils libr…
Browse files Browse the repository at this point in the history
…ary for street view metadata
  • Loading branch information
wangela committed Oct 21, 2023
1 parent 71ca330 commit 2f445a4
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ You no longer need to specify the Maps SDK for Android or its Utility Library as
dependencies {
implementation 'com.google.maps.android:maps-compose:3.1.1'
// Optionally, you can include the Compose utils library for Clustering, etc.
// Optionally, you can include the Compose utils library for Clustering,
// Street View metadata checks, etc.
implementation 'com.google.maps.android:maps-compose-utils:3.1.1'
// Optionally, you can include the widgets library for ScaleBar, etc.
Expand Down Expand Up @@ -232,6 +233,16 @@ MarkerInfoWindow(
You can add a Street View given a location using the `StreetView` composable.
To use it, provide a `StreetViewPanoramaOptions` object as follows:

1. Test whether a Street View location is valid with the the
`fetchStreetViewData` utility from the [`maps-compose-utils` library](#maps-compose-utility-library).

```kotlin
streetViewResult =
fetchStreetViewData(singapore, BuildConfig.MAPS_API_KEY)
```

2. Once the location is confirmed valid, add a Street View composable.

```kotlin
val singapore = LatLng(1.3588227, 103.8742114)
StreetView(
Expand All @@ -241,17 +252,6 @@ StreetView(
)
```

In order to test whether that Street View location is valid, we recommend using the
`fetchStreetViewData` utility from the [Maps SDK for Android Utility Library](https://github.com/googlemaps/android-maps-utils). We showcase an example of this
in [`StreetViewActivity`](https://github.com/googlemaps/android-maps-compose/blob/main/app/src/main/java/com/google/maps/android/compose/StreetViewActivity.kt) of the demo app:

```kotlin
streetViewResult =
fetchStreetViewData(singapore, BuildConfig.MAPS_API_KEY)
```

Be sure to [enable Street View Static API](https://goo.gle/enable-sv-static-api) on the project associated with your API key.

</details>

<details>
Expand All @@ -275,9 +275,9 @@ GoogleMap(

</details>

## Utility Library
## Maps Compose Utility Library

This library also provides optional utilities in the `maps-compose-utils` library from the [Maps SDK for Android Utility Library](https://github.com/googlemaps/android-maps-utils).
This library provides optional utilities in the `maps-compose-utils` library from the [Maps SDK for Android Utility Library](https://github.com/googlemaps/android-maps-utils).

### Clustering

Expand All @@ -300,7 +300,22 @@ Clustering(
)
```

## Widgets
### Street View metadata utility

The `fetchStreetViewData` method provides functionality to check whether a location is supported in StreetView. You can avoid errors when adding a Street View panorama to an Android app by calling this metadata utility and only adding a Street View panorama if the response is OK.

> [!IMPORTANT]
> Be sure to [enable Street View Static API](https://goo.gle/enable-sv-static-api) on the project associated with your API key.
You can see example usage
in the [`StreetViewActivity`](https://github.com/googlemaps/android-maps-compose/blob/main/app/src/main/java/com/google/maps/android/compose/StreetViewActivity.kt) of the demo app:

```kotlin
streetViewResult =
fetchStreetViewData(singapore, BuildConfig.MAPS_API_KEY)
```

## Maps Compose Widgets

This library also provides optional composable widgets in the `maps-compose-widgets` library that you can use alongside the `GoogleMap` composable.

Expand Down

0 comments on commit 2f445a4

Please sign in to comment.