public final class

MapCameraUpdate

extends Object
java.lang.Object
   ↳ com.neomades.maps.camera.MapCameraUpdate

Class Overview

Defines a camera move. An object of this type can be used to modify a map's camera by calling animate(MapCameraUpdate) or move(MapCameraUpdate).

Summary

Public Methods
static MapCameraUpdate newLocation(MapCamera camera, Location position)
Returns a MapCameraUpdate that moves the camera to a specified position.
static MapCameraUpdate newLocationBounds(MapCamera camera, LocationBounds bounds, int padding)
Returns a MapCameraUpdate that transforms the camera such that the specified latitude/longitude bounds are centered on screen at the greatest possible zoom level.
static MapCameraUpdate newLocationBounds(MapCamera camera, LocationBounds bounds, int width, int height, int padding)
Returns a MapCameraUpdate that transforms the camera such that the specified latitude/longitude bounds are centered on screen within a bounding box of specified dimensions at the greatest possible zoom level.
static MapCameraUpdate newLocationZoom(MapCamera camera, Location position, float zoom)
Returns a MapCameraUpdate that moves the center of the screen to a latitude and longitude specified by a Location object, and moves to the given zoom level.
static MapCameraUpdate scrollBy(MapCamera camera, float x, float y)
Returns a MapCameraUpdate that scrolls the camera over the map, shifting the center of view by the specified number of pixels in the x and y directions.
static MapCameraUpdate zoomBy(MapCamera camera, float amount, Point focus)
Returns a MapCameraUpdate that shifts the zoom level of the current camera viewpoint.
static MapCameraUpdate zoomBy(MapCamera camera, float amount)
Returns a MapCameraUpdate that shifts the zoom level of the current camera viewpoint.
static MapCameraUpdate zoomIn(MapCamera camera)
Returns a MapCameraUpdate that zooms in on the map by moving the viewpoint's height closer to the Earth's surface.
static MapCameraUpdate zoomOut(MapCamera camera)
Returns a MapCameraUpdate that zooms out on the map by moving the viewpoint's height farther away from the Earth's surface.
static MapCameraUpdate zoomTo(MapCamera camera, float zoom)
Returns a MapCameraUpdate that moves the camera viewpoint to a particular zoom level.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static MapCameraUpdate newLocation (MapCamera camera, Location position)

Returns a MapCameraUpdate that moves the camera to a specified position.

This creates a transformation from the camera position object's latitude, longitude, zoom level, bearing and tilt.

Parameters
camera from which maps camera
position a Location object containing the desired latitude and longitude.
Returns
  • a new camera update

public static MapCameraUpdate newLocationBounds (MapCamera camera, LocationBounds bounds, int padding)

Returns a MapCameraUpdate that transforms the camera such that the specified latitude/longitude bounds are centered on screen at the greatest possible zoom level.

You can specify padding, in order to inset the bounding box from the map view's edges. The returned MapCameraUpdate has a bearing of 0 and a tilt of 0.

Do not change the camera with this camera update until the map has undergone layout (in order for this method to correctly determine the appropriate bounding box and zoom level, the map must have a size). Otherwise an IllegalStateException will be thrown. It is NOT sufficient for the map to be available (i.e. getMap() returns a non-null object); the view containing the map must have also undergone layout such that its dimensions have been determined. If you cannot be sure that this has occured, use newCameraUpdate(MapCamera, LocationBounds, int, int, int) instead and provide the dimensions of the map manually.

Parameters
camera from which maps camera
bounds region to fit on screen
padding space (in px) to leave between the bounding box edges and the view edges. This value is applied to all four sides of the bounding box.
Returns
  • a new camera update

public static MapCameraUpdate newLocationBounds (MapCamera camera, LocationBounds bounds, int width, int height, int padding)

Returns a MapCameraUpdate that transforms the camera such that the specified latitude/longitude bounds are centered on screen within a bounding box of specified dimensions at the greatest possible zoom level.

You can specify additional padding, to further restrict the size of the bounding box. The returned MapCameraUpdate has a bearing of 0 and a tilt of 0.

Unlike newCameraUpdate(MapCamera, LocationBounds, int), you can use the MapCameraUpdate returned by this method to change the camera prior to the map's layout phase, because the arguments specify the desired size of the bounding box.

Parameters
camera from which maps camera
bounds region to fit on screen
width bounding box width in pixels (px)
height bounding box height in pixels (px)
padding space (in px) to leave between the bounding box edges and the view edges. This value is applied to all four sides of the bounding box.
Returns
  • a new camera update

public static MapCameraUpdate newLocationZoom (MapCamera camera, Location position, float zoom)

Returns a MapCameraUpdate that moves the center of the screen to a latitude and longitude specified by a Location object, and moves to the given zoom level.

Parameters
camera from which maps camera
Returns
  • a new camera update

public static MapCameraUpdate scrollBy (MapCamera camera, float x, float y)

Returns a MapCameraUpdate that scrolls the camera over the map, shifting the center of view by the specified number of pixels in the x and y directions. Examples:

  • If xPixel = 5 and yPixel = 0, the system scrolls right by moving the camera so that the map appears to have shifted 5 pixels to the left.
  • If xPixel = 0 and yPixel = 5, the system scrolls down by moving the camera so that the map appears to have shifted 5 pixels upwards.

The scrolling is relative to the camera's current orientation. For example, if the camera is bearing 90 degrees, then east is "up" and scrolling right will move the camera south.

Cross Platform considerations

Not implemented on the iOS platform. Will return null.

Parameters
camera from which maps camera
x the number of pixels to scroll horizontally. A positive value moves the camera to the right, with respect to its current orientation. A negative value moves the camera to the left, with respect to its current orientation.
y the number of pixels to scroll vertically. A positive value moves the camera downwards, with respect to its current orientation. A negative value moves the camera upwards, with respect to its current orientation.
Returns
  • a new camera update

public static MapCameraUpdate zoomBy (MapCamera camera, float amount, Point focus)

Returns a MapCameraUpdate that shifts the zoom level of the current camera viewpoint.

A point specified by focus will remain fixed (i.e., it corresponds to the same lat/long both before and after the zoom process).

This method is different to zoomTo(float) in that zoom is relative to the current camera.

For example, if the LatLng (11.11, 22.22) is currently at the screen location (23, 45). After calling this method with a zoom amount and this LatLng, the screen location of this LatLng will still be (23, 45).

Cross Platform considerations

Not implemented on the iOS platform. Will return null.

Parameters
camera from which maps camera
amount amount to change the zoom level. Positive values indicate zooming closer to the surface of the Earth while negative values indicate zooming away from the surface of the Earth.
focus pixel location on the screen that is to remain fixed after the zooming process. The lat/long that was at that pixel location before the camera move will remain the same after the camera has moved.
Returns
  • a new camera update

public static MapCameraUpdate zoomBy (MapCamera camera, float amount)

Returns a MapCameraUpdate that shifts the zoom level of the current camera viewpoint.

This method is different to zoomTo(float) in that zoom is relative to the current camera.

Cross Platform considerations

Not implemented on the iOS platform. Will return null.

Parameters
camera from which maps camera
amount amount to change the zoom level. Positive values indicate zooming closer to the surface of the Earth while negative values indicate zooming away from the surface of the Earth.
Returns
  • a new camera update

public static MapCameraUpdate zoomIn (MapCamera camera)

Returns a MapCameraUpdate that zooms in on the map by moving the viewpoint's height closer to the Earth's surface. The zoom increment is 1.0.

Cross Platform considerations

Not implemented on the iOS platform. Will return null.

Parameters
camera from which maps camera
Returns
  • a new camera update

public static MapCameraUpdate zoomOut (MapCamera camera)

Returns a MapCameraUpdate that zooms out on the map by moving the viewpoint's height farther away from the Earth's surface. The zoom increment is -1.0.

Cross Platform considerations

Not implemented on the iOS platform. Will return null.

Parameters
camera from which maps camera
Returns
  • a new camera update

public static MapCameraUpdate zoomTo (MapCamera camera, float zoom)

Returns a MapCameraUpdate that moves the camera viewpoint to a particular zoom level.

Cross Platform considerations

Not implemented on the iOS platform. Will return null.

Parameters
camera from which maps camera
zoom the desired zoom level, in the range of 2.0 to 21.0. Values below this range are set to 2.0, and values above it are set to 21.0. Increase the value to zoom in. Not all areas have tiles at the largest zoom levels.
Returns
  • a new camera update