Skip to content

fix(maps-compose): apply mapColorScheme to GoogleMapOptions during MapView creation - #976

Merged
dkhawk merged 1 commit into
mainfrom
fix/terrain-dark-mode-map-color-scheme
Aug 21, 2026
Merged

fix(maps-compose): apply mapColorScheme to GoogleMapOptions during MapView creation#976
dkhawk merged 1 commit into
mainfrom
fix/terrain-dark-mode-map-color-scheme

Conversation

@dkhawk

@dkhawk dkhawk commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

GoogleMap() currently applies mapColorScheme via map.setMapColorScheme() only after getMapAsync() completes. However, the Maps SDK's terrain renderer only respects FOLLOW_SYSTEM/DARK when it is present in GoogleMapOptions at MapView creation time; calling setMapColorScheme() later on an already-initialized terrain map with custom MapStyleOptions fails to trigger dark terrain shaders.

This change updates AndroidView's factory in GoogleMap.kt to automatically populate GoogleMapOptions.mapColorScheme from the mapColorScheme parameter if it has not been explicitly configured in googleMapOptionsFactory.

Also fixes GoogleMapViewTests.kt to replace vacuous tests (which asserted against a test-local variable) with real assertions against the GoogleMapOptions passed to mapViewFactory, and adds a test verifying that an explicitly configured googleMapOptionsFactory is not overwritten.

Verified via ./gradlew :maps-compose:compileDebugKotlin and test suite.

@dkhawk
dkhawk requested a review from kikoso August 21, 2026 16:10
@dkhawk
dkhawk force-pushed the fix/terrain-dark-mode-map-color-scheme branch from 8bb89cd to 422622f Compare August 21, 2026 16:16

@kikoso kikoso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dkhawk
dkhawk force-pushed the fix/terrain-dark-mode-map-color-scheme branch 5 times, most recently from 01754fc to d84fc14 Compare August 21, 2026 17:40
…pView creation

GoogleMap() currently only applies mapColorScheme via map.setMapColorScheme()
after getMapAsync() completes. However, the Maps SDK's terrain renderer
only respects FOLLOW_SYSTEM/DARK when it is present in GoogleMapOptions at
MapView creation time; calling setMapColorScheme() later on an already-initialized
terrain map with custom MapStyleOptions fails to trigger dark terrain shaders.

This change updates AndroidView's factory in GoogleMap.kt to automatically
populate GoogleMapOptions.mapColorScheme from the mapColorScheme parameter if
it has not been explicitly configured in googleMapOptionsFactory (where 0 / MapColorScheme.LIGHT is the Java int default).

Also fixes GoogleMapViewTests.kt to replace vacuous tests (which asserted against
a test-local variable) with real assertions against the GoogleMapOptions passed to
mapViewFactory, and adds a test verifying that an explicitly configured
googleMapOptionsFactory is not overwritten.

Verified via ./gradlew :maps-compose:compileDebugKotlin and test suite.
@dkhawk
dkhawk force-pushed the fix/terrain-dark-mode-map-color-scheme branch from d84fc14 to bcceb4b Compare August 21, 2026 17:41
@googlemaps-bot

googlemaps-bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 25.74%

There is no coverage information present for the Files changed

@dkhawk
dkhawk merged commit 7dec2b7 into main Aug 21, 2026
13 checks passed
@dkhawk
dkhawk deleted the fix/terrain-dark-mode-map-color-scheme branch August 21, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants