Android SupportMapFragment设置谷歌地图缩放级别

Android SupportMapFragment设置谷歌地图缩放级别,android,zooming,supportmapfragment,Android,Zooming,Supportmapfragment,如何设置SupportMapFragment的缩放级别? 我尝试了一些在类似问题中找到的答案,比如下面这个回答:买一个叫Rob的家伙,他提出: LatLng currentLocation = mService.getCurrentLocation(); CameraPosition cameraPosition = new CameraPosition.Builder() .target(currentLocation) // Sets the cente

如何设置
SupportMapFragment
的缩放级别? 我尝试了一些在类似问题中找到的答案,比如下面这个回答:买一个叫Rob的家伙,他提出:

LatLng currentLocation = mService.getCurrentLocation();
    CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(currentLocation)    // Sets the center of the map to the current location of the user
            .zoom(17)                   // Sets the zoom
            .bearing(90)                // Sets the orientation of the camera to east
            .tilt(30)                   // Sets the tilt of the camera to 30 degrees
            .build();                   // Creates a CameraPosition from the builder
    mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

但这个解决方案不起作用。那么,在知道我使用了
SupportMapFragment

的情况下,如何设置缩放级别?如果您的当前位置不为空,请尝试此代码,它将正常工作

LatLng currentLocation = mService.getCurrentLocation();
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(currentLocation , 16);
mMap.addMarker(new MarkerOptions().position(location).title(""));
mMap.moveCamera(CameraUpdateFactory.newLatLng(currentLocation ));
mMap.animateCamera(cameraUpdate)

如果您的当前位置不为空,请尝试此代码,它将正常工作

LatLng currentLocation = mService.getCurrentLocation();
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(currentLocation , 16);
mMap.addMarker(new MarkerOptions().position(location).title(""));
mMap.moveCamera(CameraUpdateFactory.newLatLng(currentLocation ));
mMap.animateCamera(cameraUpdate)