-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Retrieve map state while switching between fragments #26
Comments
there is no answers or updates or any workaround to this issue ? |
it is old, I guess the only way is that you save the state of the map before any change then reload it again from the stack cheers |
thanks 💯 |
didn't get your ans. please elaborate little bit more @AryaRDI . |
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! |
i have same trouble |
In the future, for help with specific situations you'll get the fastest response on StackOverflow (tag google-maps-android-api-2). For this question, you may want to check out the demos for RetainMap and SaveState. |
You could try to "Add" fragments instead of replacing them. Example:
|
Well it's maybe too late and the problem is solved, but for others with that problem the solution from me can help. I had the same problem with a laggy map when switching between fragments from navigation in one activity. I think it's a specific way to implement such a structure but anyway. So the solution for the map to just save the map in its rendered status and don't mess up recreating it when getting back to the fragment, is to check if its not null. so I use the MapFragment, but you could change your code to fit into it. In your MainFragment.java you have to check it your actual Map is not null In the onCreateView Method from Fragment:
So the getMapAsync Task is only called when there is no initialized Map and while there was one he is using it. |
hi guys,
i need a hand about this issue, im using NavigationDrawer in my code and every time user choose an item from:
onNavigationItemSelected(MenuItem item)
a fragment will be loaded, 1 have a fragment which i implemented a map inside with some markers and clusters the problem is when the user go to another fragment and he comeback again to the fragment with map all these markers and clusters going to be generated again and it makes the app really slow what you suggest for it?MainActivity:
MainFragment:
The text was updated successfully, but these errors were encountered: