CameraPosition

public final classCameraPositionextendsObject
implementsParcelableParcelable

An immutable class that aggregates all camera position parameters such as location, zoom level, tilt angle, and bearing. UseCameraPosition.Builder to construct aCameraPosition instance, which you can then use in conjunction withCameraUpdateFactory. For more information, seeMoving the camera.

Developer Guide

For more information, read theCamera and Viewdeveloper guide.

Nested Class Summary

class CameraPosition.Builder Builds camera position.

Inherited Constant Summary

Field Summary

public final float bearing Direction that the camera is pointing in, in degrees clockwise from north.
public finalLatLng target The location that the camera is pointing at.
public final float tilt The angle, in degrees, of the camera angle from the nadir (directly facing the Earth).
public final float zoom Zoom level near the center of the screen.

Public Constructor Summary

CameraPosition(LatLng target, float zoom, float tilt, float bearing)
Constructs a CameraPosition.

Public Method Summary

staticCameraPosition.Builder
builder(CameraPosition camera)
Creates a builder for a camera position, initialized to a given position.
staticCameraPosition.Builder
builder()
Creates a builder for a camera position.
staticCameraPosition
createFromAttributes(Context context,AttributeSet attrs)
Creates a CameraPosition from theAttributeSet.
boolean
staticCameraPosition
fromLatLngZoom(LatLng target, float zoom)
Constructs a CameraPosition pointed for a particular target and zoom level.
int
String
void
writeToParcel(Parcelout, int flags)

Inherited Method Summary

Fields

public final float bearing

Direction that the camera is pointing in, in degrees clockwise from north.

public finalLatLng target

The location that the camera is pointing at.

public final float tilt

The angle, in degrees, of the camera angle from the nadir (directly facing the Earth). See CameraPosition.Builder.tilt(float)for details of restrictions on the range of values.

public final float zoom

Zoom level near the center of the screen. See CameraPosition.Builder.zoom(float)for the definition of the camera's zoom level.

Public Constructors

publicCameraPosition(LatLngtarget, float zoom, float tilt, float bearing)

Constructs a CameraPosition.

Parameters
target The target location to align with the center of the screen. Must not be null.
zoom Zoom level at target. See CameraPosition.Builder.zoom(float)for details of restrictions.
tilt The camera angle, in degrees, from the nadir (directly down). See CameraPosition.Builder.tilt(float)for details of restrictions.
bearing Direction that the camera is pointing in, in degrees clockwise from north. This value will be normalized to be within 0 degrees inclusive and 360 degrees exclusive.
Throws
NullPointerException iftargetisnull
IllegalArgumentException iftiltis outside the range of 0 to 90 degrees inclusive.

Public Methods

public staticCameraPosition.Builder builder(CameraPosition camera)

Creates a builder for a camera position, initialized to a given position.

public staticCameraPosition.Builder builder()

Creates a builder for a camera position.

public staticCameraPosition createFromAttributes(Contextcontext, AttributeSet attrs)

Creates a CameraPosition from theAttributeSet.

Returns
  • nullif eithercontextorattrsis null.

public booleanequals(Objecto)

public staticCameraPosition fromLatLngZoom(LatLngtarget, float zoom)

Constructs a CameraPosition pointed for a particular target and zoom level. The resultant bearing is North, and the viewing angle is perpendicular to the Earth's surface. i.e., directly facing the Earth's surface, with the top of the screen pointing North.

Parameters
target The target location to align with the center of the screen.
zoom Zoom level at target. See CameraPosition.Builder.zoom(float)for details on the range the value will be clamped to. The larger the value the more zoomed in the camera is.

public inthashCode()

publicStringtoString()

public voidwriteToParcel(Parcelout, int flags)