Hide

CameraPosition.Builder

public static final class CameraPosition.Builder extends Object
java.lang.Object
   ↳ com.google.android.gms.maps.model.CameraPosition.Builder

Builds camera position.

Public Constructors

public CameraPosition.Builder ()

Creates an empty builder.

public CameraPosition.Builder (CameraPosition previous)

Public Methods

public CameraPosition.Builder bearing (float bearing)

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

public CameraPosition build ()

Builds a CameraPosition.

public CameraPosition.Builder target (LatLng location)

Sets the location that the camera is pointing at.

public CameraPosition.Builder tilt (float tilt)

Sets the angle, in degrees, of the camera from the nadir (directly facing the Earth). When changing the camera position for a map, this value is restricted depending on the zoom level of the camera. The restrictions are as follows:

  • For zoom levels less than 10 the maximum is 30.
  • For zoom levels from 10 to 14 the maximum increases linearly from 30 to 45 (e.g. at zoom level 12, the maximum is 37.5).
  • For zoom levels from 14 to 15.5 the maximum increases linearly from 45 to 67.5.
  • For zoom levels greater than 15.5 the maximum is 67.5.
The minimum is always 0 (directly down). If you specify a value outside this range and try to move the camera to this camera position it will be clamped to these bounds.

public CameraPosition.Builder zoom (float zoom)

Sets the zoom level of the camera. Zoom level is defined such that at zoom level 0, the whole world is approximately 256dp wide (assuming that the camera is not tilted). Increasing the zoom level by 1 doubles the width of the world on the screen. Hence at zoom level N, the width of the world is approximately 256 * 2 N dp, i.e., at zoom level 2, the whole world is approximately 1024dp wide.

When changing the camera position for a map, the zoom level of the camera is restricted to a certain range depending on various factors including location, map type and map size. Use GoogleMap.getMinZoomLevel and GoogleMap.getMaxZoomLevel to find the restrictions. Note that the camera zoom need not be an integer value.