Skip to content
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

Map Color Scheme not working on first app launch #597

Closed
RyeGordo opened this issue Jul 6, 2024 · 8 comments
Closed

Map Color Scheme not working on first app launch #597

RyeGordo opened this issue Jul 6, 2024 · 8 comments
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@RyeGordo
Copy link

RyeGordo commented Jul 6, 2024

The Map color scheme added in version 6.0.0 does not work when the app is first launched.

If mapColorScheme is set to ComposeMapColorScheme.DARK or ComposeMapColorScheme.FOLLOW_SYSTEM with the system OS in Dark Mode, the Google Map will render as ComposeMapColorScheme.LIGHT when the app is first launched (after app install or clearing app data).

Dynamic changes to to mapColorScheme are ignored, and the Google Map continue to display in ComposeMapColorScheme.LIGHT
See DynamicMapTheme.zip for sample app with implementation of button selection to change the colour scheme.
(You will need to generate an API key)

The Google Map will behave correctly after killing the app and restarting

  • the default DARK colour scheme is respected
  • dynamic colour scheme changes are working

Environment details

API 34
Kotlin 2.0
Java 21
com.google.maps.android:maps-compose:6.0.0

Steps to reproduce

  1. Launch App
  2. Observe ComposeMapColorScheme.DARK is not respected
  3. Observe button selections to change colour scheme are not working
  4. Kill app and restart
  5. Observe ComposeMapColorScheme.DARK is displayed correctly
  6. Observe button selections to change colour are now working

Code example

@Composable
private fun MapContent(modifier: Modifier) {
    val mapUiSettings by remember {
        mutableStateOf(MapUiSettings(mapToolbarEnabled = false, myLocationButtonEnabled = true, zoomControlsEnabled = false))
    }

    /**
     * Dynamic Map Compose Theme with Default set to [ComposeMapColorScheme.DARK]
     */
    var mapColorScheme by remember {
        mutableStateOf(ComposeMapColorScheme.DARK)
    }
    Box(
        modifier = modifier,
        contentAlignment = Alignment.BottomCenter
    ) {
        GoogleMap(
            uiSettings = mapUiSettings,
            mapColorScheme = mapColorScheme
        )

        Row(
            Modifier
                .fillMaxWidth()
                .padding(bottom = 32.dp),
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.SpaceEvenly
        ) {
            Button(onClick = { mapColorScheme = ComposeMapColorScheme.FOLLOW_SYSTEM }) {
                Text(text = "System")
            }
            Button(onClick = { mapColorScheme = ComposeMapColorScheme.LIGHT }) {
                Text(text = "Light")
            }
            Button(onClick = { mapColorScheme = ComposeMapColorScheme.DARK }) {
                Text(text = "Dark")
            }
        }
    }
}

See DynamicMapTheme.zip for sample app with implementation of button selection for dynamic colour scheme.
(You will need to generate an API key)

@RyeGordo RyeGordo added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jul 6, 2024
@kikoso
Copy link
Collaborator

kikoso commented Jul 8, 2024

Hi @RyeGordo . This is an underlying issue on the version 19.0.0 of the Play Services SDK, and eventually due to the new renderer. We had similar issues with the AdvancedMarkers.

@RyeGordo
Copy link
Author

RyeGordo commented Jul 8, 2024

Thanks for the quick feedback.
I guess we have no choice but to wait patiently for the next version of the Play Services SDK.

@kikoso
Copy link
Collaborator

kikoso commented Jul 8, 2024

Correct. Although annoying, this seems to happen when the app starts for the first time (probably due to some internal flag initialization in the SDK). On subsequent starts the problem disappears.

@kikoso
Copy link
Collaborator

kikoso commented Jul 9, 2024

I have filled a bug on the issue tracker: https://issuetracker.google.com/issues/351858982

@RyeGordo
Copy link
Author

RyeGordo commented Jul 9, 2024

Thanks. I gave it a +1. Hopefully we get a response soon.

@RyeGordo
Copy link
Author

Any progress on this?

There's a request for demo sample code on the Maps SDK issue (https://issuetracker.google.com/issues/351858982)
Would you like me to provide a sample for them?

@kikoso
Copy link
Collaborator

kikoso commented Jul 26, 2024

For the record: the Maps Team has answered. This is a temporary behavior that will be deactivated at some point:

https://issuetracker.google.com/issues/351858982#comment7

@kikoso kikoso closed this as completed Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
2 participants