-
Notifications
You must be signed in to change notification settings - Fork 165
fix: add one-time attribution ID initialization for GoogleMap #735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matejdro
reviewed
Aug 14, 2025
maps-compose/src/main/java/com/google/maps/android/compose/GoogleMap.kt
Outdated
Show resolved
Hide resolved
Does this call need to be made more often than once per startup? Otherwise it could be moved into a singleton file to ensure that this call is not made multiple times when map is created multiple times. |
Refactored the Maps API initialization logic into a new `MapsApiAttribution` singleton. This ensures that `MapsApiSettings.addInternalUsageAttributionId` is called only once per application lifecycle. The `isInitialized` state is now managed within the singleton and exposed as a Compose `State`, triggering recomposition in the `GoogleMap` composable when the API is ready. This simplifies the `GoogleMap` composable and provides a single source of truth for initialization status.
dkhawk
approved these changes
Aug 15, 2025
googlemaps-bot
pushed a commit
that referenced
this pull request
Aug 19, 2025
## [6.7.2](v6.7.1...v6.7.2) (2025-08-19) ### Bug Fixes * add one-time attribution ID initialization for GoogleMap ([#735](#735)) ([236f23a](236f23a))
🎉 This PR is included in version 6.7.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Thanks, the fix seems to be working. |
dkhawk
added a commit
to akexorcist/android-maps-compose
that referenced
this pull request
Aug 27, 2025
…maps#735) * fix: add one-time attribution ID initialization for GoogleMap * fix: removed addInternalUsageAttributionId usage * fix: running only once on PR * fix: running tests only on PR * feat: Centralize Maps API initialization in a singleton Refactored the Maps API initialization logic into a new `MapsApiAttribution` singleton. This ensures that `MapsApiSettings.addInternalUsageAttributionId` is called only once per application lifecycle. The `isInitialized` state is now managed within the singleton and exposed as a Compose `State`, triggering recomposition in the `GoogleMap` composable when the API is ready. This simplifies the `GoogleMap` composable and provides a single source of truth for initialization status. * refactor: Improve Maps API attribution initialization --------- Co-authored-by: dkhawk <107309+dkhawk@users.noreply.github.com>
dkhawk
pushed a commit
to akexorcist/android-maps-compose
that referenced
this pull request
Aug 27, 2025
## [6.7.2](googlemaps/android-maps-compose@v6.7.1...v6.7.2) (2025-08-19) ### Bug Fixes * add one-time attribution ID initialization for GoogleMap ([googlemaps#735](googlemaps#735)) ([236f23a](googlemaps@236f23a))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request updates the
GoogleMap
composable to perform a one-time initialization of the Maps API attribution ID before rendering the map. ALaunchedEffect
is used to call MapsApiSettings.addInternalUsageAttributionId on a background thread, and the map only renders once this initialization is complete. This ensures that the internal usage attribution is correctly set.This PR also activates the StrictMode.
Fixes #732 🦕