Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ To run the demo app, ensure you've met the requirements above then:

See the [documentation] for a full list of classes and their methods.

## Internal usage attribution ID

This library calls the MapsApiSettings.addInternalUsageAttributionId method, which helps Google
understand which libraries and samples are helpful to developers and is optional. Instructions for
opting out of the identifier are provided in
[reference documentation](maps-compose/src/main/java/com/google/maps/android/compose/internal/MapsApiAttribution.kt).

## Usage

Adding a map to your app looks like the following:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,30 @@ internal object MapsApiAttribution {
private val _isInitialized = mutableStateOf(false)
val isInitialized: State<Boolean> = _isInitialized

/**
* The value of the attribution ID. Set this to the empty string to opt out of attribution.
*
* This must be set before calling the GoogleMap composable.
*/
var attributionId: String = AttributionId.VALUE

/**
* Adds the attribution ID to the Maps API settings. This is done on a background thread
* using [Dispatchers.IO]. The attribution ID is only added once.
*
* Adds a usage attribution ID to the initializer, which helps Google understand which libraries
* and samples are helpful to developers, such as usage of this library.
* To opt out of sending the usage attribution ID, it is safe to delete this function call
* or replace the value with an empty string.
*
* See https://developers.google.com/android/reference/com/google/android/gms/maps/MapsApiSettings#addInternalUsageAttributionId(android.content.Context,%20java.lang.String)
*
* @param context The context to use to add the attribution ID.
*/
suspend fun addAttributionId(context: Context) {
if (hasBeenCalled.compareAndSet(false, true)) {
withContext(Dispatchers.IO) {
MapsApiSettings.addInternalUsageAttributionId(context, AttributionId.VALUE)
MapsApiSettings.addInternalUsageAttributionId(context, attributionId)
_isInitialized.value = true
}
}
Expand Down
Loading