KEMBAR78
fix: add one-time attribution ID initialization for GoogleMap by kikoso · Pull Request #735 · googlemaps/android-maps-compose · GitHub
Skip to content

Conversation

kikoso
Copy link
Collaborator

@kikoso kikoso commented Aug 13, 2025

This pull request updates the GoogleMap composable to perform a one-time initialization of the Maps API attribution ID before rendering the map. A LaunchedEffect 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 🦕

@matejdro
Copy link

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.

@kikoso kikoso requested a review from a team as a code owner August 15, 2025 15:20
kikoso and others added 3 commits August 15, 2025 17:21
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 dkhawk merged commit 236f23a into main Aug 19, 2025
10 of 11 checks passed
@dkhawk dkhawk deleted the fix/google_map_init branch August 19, 2025 19:34
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))
@googlemaps-bot
Copy link
Contributor

🎉 This PR is included in version 6.7.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@matejdro
Copy link

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maps compose is doing disk reads on the main thread and slows down map to a crawl when detectDiskReads is enabled

4 participants