Skip to main content

The camera


The camera is how the user views the map. It can be centered on a location, zoomed, tilted, rotated and moved. The camera can be set programmatically but also controlled through user interaction with gestures.

The camera is typically set using the CameraPosition class which is made up of target, zoom, bearing and tilt parameters.

Attribute Type Description Default Setting
LatLng object
Where the camera should center on the map. Required
The zoom level of the camera; ranges from 0 to 22. 0
The rotation of the camera in degrees clockwise from north. 0 (true north)
The camera’s angle when viewing the map. Ranges from 0 to 60. 0 (bird’s eye view)

Setting the CameraPosition

There are many ways to set the camera position on the map, but the most common method is to use the CameraPosition’s Builder. An example:

The above code sets the camera’s target/center to be a coordinate in New York City and sets the zoom level to 13. Once the CameraPosition is built, the map is updated with the new position.

Animating the CameraPosition

In addition to setting the map’s camera position, you can also animate a “flight” for the new camera position information, gliding into it. The map’s animateCamera() method allows for this using a CameraUpdate object as a parameter. An example of this is below:

Similar to the previous example, the CameraPosition is created, CameraUpdateFactory can then use this position to generate the CameraUpdate object animateCamera() requires. The second parameter is an optional duration for the animation in milliseconds.

Last updated September 19, 2023.