In my project im trying to implementthis solution for managing a map in a dynamic added fragment.
public class MapFragment extends Fragment {
private GoogleM
Since you are using nested fragments, you should use getChildFragmentManager()
SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
And I recommend you to use getMapAsync method, because getMap is deprecated
mapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
setupMap(googleMap);
}
});
You need to use findViewById on the view you get, not using the fragment manager. The map is attached to the view
View v =inflater.inflate(R.layout.fragment_map, container, false);
map = v.findViewById(R.id.map))
.getMap();