Ryuzaki Ryuzaki - 4 months ago 25
Android Question

google maps using viewpager(in a tab) and getMapAsync()

i want to put google maps in a tab using viewPager ,thus viewPager uses fragments, i found multiple solutions that use the deprecated getMap, so android studio wouldn't even compile it, is there any up to date solution to get the map with viewPager ?


In onCreateView in the mapsActivity.java that extends android.support.v4.app.Fragment and implements OnMapReadyCallback :

View rootView =inflater.inflate(R.layout.activity_maps, container, false);

Obtain the SupportMapFragment and get notified when the map is ready to be used.

SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);