I\'m working through a tutorial and my app is basically working except for one small detail. I have an Options menu to demonstrate things like showing the map as a Satellite vie
Initially when first time your GoogleMap
loads takes some time and there fore Location
will be null.
So for your both menu options check this way.
if(map!=null){
map.setMyLocationEnabled(true);
}
if(map!=null){
Location myLocation = map.getMyLocation();
if(myLocation !=null){
LatLng myLatLng = new LatLng(myLocation.getLatitude(),
myLocation.getLongitude());
CameraPosition myPosition = new CameraPosition.Builder()
.target(myLatLng).zoom(17).bearing(90).tilt(30).build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(myPosition));
}
}