mdtuyen
mdtuyen

Reputation: 4548

How to use SupportMapFragment inside Fragment?

I know this question have many duplicate in Stackoverflow but when I use lib support 9.6.1 some function (as getMap) have been removed.

Basically I will call:

    ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.google_map)).getMapAsync(this);

and implement OnMapReadyCallback interface for this Fragment.

However, If I have many Fragment put to and R.id.container. When I switch MapFragment by other fragment every thing must recall => Map reload, data reload, ....

It is a poor for practice. I don't want to redo, it make my application so bad performance.

Please show me a good solution to use the map.

Upvotes: 2

Views: 1199

Answers (2)

ediBersh
ediBersh

Reputation: 1135

just use different Views as acontainers, and switch visibility between them. view1.setVisibility(View.GONE) view2.setVisibility(View.VISIBLE)

Upvotes: 2

Ionut-Mihai Nicula
Ionut-Mihai Nicula

Reputation: 76

You can use to different containers -> Two different FrameLayouts with different id's.

In one of them keep only the map and hide the FrameLayout when you don't want to display it.

view.setVisibility(View.GONE)

Upvotes: 1

Related Questions