Ryuzaki Ryuzaki - 1 year ago 139
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 ?

Answer Source

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);   

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download