Git Product home page Git Product logo

Comments (9)

mohamedagamy avatar mohamedagamy commented on May 22, 2024 1

thanks 💯

from android-samples.

Photon-thing avatar Photon-thing commented on May 22, 2024 1

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:

if (mMap == null) {
fusedLocationProviderClient = getFusedLocationProviderClient(getActivity());
SupportMapFragment supportMapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.mapView);
supportMapFragment.getMapAsync(this);
}

So the getMapAsync Task is only called when there is no initialized Map and while there was one he is using it.

from android-samples.

mohamedagamy avatar mohamedagamy commented on May 22, 2024

there is no answers or updates or any workaround to this issue ?

from android-samples.

AryaRDI avatar AryaRDI commented on May 22, 2024

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

from android-samples.

basitsaleemmb avatar basitsaleemmb commented on May 22, 2024

didn't get your ans. please elaborate little bit more @AryaRDI .
thanks !

from android-samples.

stale avatar stale commented on May 22, 2024

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!

from android-samples.

alneil avatar alneil commented on May 22, 2024

i have same trouble

from android-samples.

wangela avatar wangela commented on May 22, 2024

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.

from android-samples.

tutucmarin avatar tutucmarin commented on May 22, 2024

You could try to "Add" fragments instead of replacing them.
It will not destroy the previous fragment view, so it won't be necessary to reload the data.

Example:

        val fragment = TheFragment()
        val ft = requireActivity().supportFragmentManager.beginTransaction()

        ft.add(R.id.fragment_container, fragment)
        ft.commit()

from android-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.