Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -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].
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