diff --git a/README.md b/README.md index b72c63f0..2b60196b 100644 --- a/README.md +++ b/README.md @@ -497,6 +497,13 @@ Box(Modifier.fillMaxSize()) { The colors of the text, line, and shadow are also all configurable (e.g., based on `isSystemInDarkTheme()` on a dark map). Similarly, the `DisappearingScaleBar` animations can be configured. +## 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). + ## Contributing Contributions are welcome and encouraged! If you'd like to contribute, send us a [pull request] and refer to our [code of conduct] and [contributing guide]. diff --git a/maps-compose/src/main/java/com/google/maps/android/compose/internal/MapsApiAttribution.kt b/maps-compose/src/main/java/com/google/maps/android/compose/internal/MapsApiAttribution.kt index 0c59d8f6..6fbbeeb6 100644 --- a/maps-compose/src/main/java/com/google/maps/android/compose/internal/MapsApiAttribution.kt +++ b/maps-compose/src/main/java/com/google/maps/android/compose/internal/MapsApiAttribution.kt @@ -20,16 +20,30 @@ internal object MapsApiAttribution { private val _isInitialized = mutableStateOf(false) val isInitialized: State = _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 } }