I want google maps to show the location of the user centered at the map as at the image 1
And this is my Fragment Code:
public class MapFragment extends Fragment implements OnMapReadyCallback {
GoogleMap googleMap;
MapView mapView;
View myview;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
myview = inflater.inflate(R.layout.map_layout, container, false);
mapView = (MapView) myview.findViewById(R.id.map);
mapView.onCreate(savedInstanceState);
mapView.onResume();
mapView.getMapAsync(this);
return myview;
}
@Override
public void onMapReady(GoogleMap map) {
googleMap = map;
List<EscolasMaps> escolasMapsList = new ArrayList<EscolasMaps>();
//buscarEscolas();
if (ActivityCompat.checkSelfPermission(this.getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this.getActivity()
, Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
}
}
But when I execute it at the emulator, or at my phone, I only get the map whithout anything as show at image2