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

Save map instance #155

Open
ghost opened this issue Jun 23, 2022 · 13 comments
Open

Save map instance #155

ghost opened this issue Jun 23, 2022 · 13 comments
Assignees
Labels
priority: p4 An issue that should be addressed eventually. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@ghost
Copy link

ghost commented Jun 23, 2022

I couldn`t find a way to save google map instance so you can prevent initialization every time you change the screen, is there such a way?

@ghost ghost added triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Jun 23, 2022
@dfavaro
Copy link

dfavaro commented Jul 26, 2022

I guess it's fine for the map to be initialized every time.
Why instead don't you save the informations you need in order to initialize it again based on your needs?

@arriolac
Copy link
Contributor

I filed an issue on the Compose-side to support this as the current available APIs cannot, afaik, support this feature request. You can +1 https://issuetracker.google.com/issues/252891031

@stale
Copy link

stale bot commented Jun 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

@stale stale bot added the stale label Jun 18, 2023
@kikoso kikoso added priority: p4 An issue that should be addressed eventually. and removed triage me I really want to be triaged. labels Jul 10, 2023
@stale stale bot removed stale labels Jul 10, 2023
@PRO8L3M
Copy link

PRO8L3M commented Jul 9, 2024

Any news/plans for that?

Honestly, as I wanted to migrate from fragment-based to Compose Google Maps I've encountered issue with reloading MapView (when coming back to the screen with Map). From UX perspective this is no go for that migration because of UX regression.

@kikoso
Copy link
Collaborator

kikoso commented Jul 9, 2024

Hi @PRO8L3M .

There is a PR that will fix this issue: #436

Since this PR was created, a new Compose version was released (1.4.0), which supports overloading onReset and onRelease in the AndroidView.

Aiming to get this merged real soon.

@philip-segerfast
Copy link
Contributor

PR #436 will only allow reuse in containers which support reuse. Maybe this is achievable though depending on how the navigation is implemented etc.

@PRO8L3M
Copy link

PRO8L3M commented Jul 9, 2024

When do you expect to merge that PR?

@philip-segerfast
Copy link
Contributor

Very soon

@philip-segerfast
Copy link
Contributor

philip-segerfast commented Jul 9, 2024

It's merged in 6.1.0

@geworfener
Copy link

geworfener commented Jul 31, 2024

Also facing this on navigating back to a map screen. It is still present in 6.1.0. Created a reproducer here: https://github.com/geworfener/MapsComposeSaveStateIssue

@VinuPolly-Bonnet
Copy link

Hey all, any update on this? currently facing this issue with NavigationSuiteScaffold as the map re-initializes every-time we change the tab and come back to the map tab, very bad UX and also drops some frames when this happens.

@matejdro
Copy link

Google has recently released a survey regarding maps. It might help if we voice our support for this issue there: https://docs.google.com/forms/d/e/1FAIpQLScE9aBgy4VZAVm2J2pgrhOKgpwqcoEiKLZRB4QBd9xH7hvMiw/viewform?resourcekey=0-1rA9AdG3BF0-gFVLXqKOdg

@VinuPolly-Bonnet
Copy link

Hey all so I have temporarily approached it in an unorthodox way. For my use case with NavigationSuiteScaffold moving between the tabs was causing a lot of issues as the maps was re-initialising every-time. For now I have kept the maps always present in the background and I only change the composables for the other tabs I have. This means if the user selects the map tab, I hide the rest of the tab composables, which automatically puts the map visible to the users.

Still just an idea, here is the pseudo-code for what I had in mind:

                MapScreen(
                    modifier = Modifier,
                    cameraPositionState = cameraPositionState
                )
                AnimatedVisibility(
                    visibleState = MutableTransitionState(currentDestination != AppDestinations.MAP)
                ) {
                    AnimatedContent(
                        targetState = currentDestination,
                        label = "home_bottom_nav_anim",
                    ) { homeDestination: AppDestinations ->
                        when (homeDestination) {
                            AppDestinations.MAP -> {
                                Unit
                            }
                            AppDestinations.PROFILE -> {
                                ProfileScreen(
                                    modifier = Modifier,
                                )
                            }
                            AppDestinations.SETTINGS -> {
                                SettingsScreen(
                                    modifier = Modifier,
                                )
                            }
                        }
                    }
                }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p4 An issue that should be addressed eventually. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

9 participants