Someone could tell me why the Google Maps API is not generating the map in android studio 3.5

Asked

Viewed 68 times

1

inserir a descrição da imagem aqui

Code of the Homefragment

public class HomeFragment extends Fragment implements OnMapReadyCallback {

public HomeFragment(){
    // Required empty public constructor
}

GoogleMap mMap;


@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {

    return inflater.inflate(R.layout.fragment_home,container, false);
}

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

   if(getActivity()!=null){
        SupportMapFragment mapFragment = (SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map);
        if(mapFragment != null){
            mapFragment.getMapAsync(this);
        }
    }
}


@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    LatLng sydney = new LatLng(-34, 151);
    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}

}

Code of the xml

<include layout="@layout/activity_maps"/>

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.