I am currently working on a Fragment with a Google Map in it. Once a user visits that fragment his map should zoom and focus on his location. However, it shows map of the wo
Sorry but that's just much too much overhead (above), short and quick, if you have the MapFragment, you also have to map, just do the following:
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
googleMap.setMyLocationEnabled(true)
} else {
// Show rationale and request permission.
}
zoom works like that:
val cameraPosition = CameraPosition.Builder().target(LatLng(location.latitude, location.longitude)).zoom(17.0.toFloat()).build()
val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition)
googleMap?.moveCamera(cameraUpdate)
Code is in Kotlin, hope you don't mind. 17.0f is some quite detailed zoom level. Just try different values.
have fun