Map Camera¶
The Mappls Maps SDK camera represents the user’s viewpoint over the map. It provides flexible options to set, update, and animate the camera position, as well as listen for camera movement events and retrieve the current camera state at any time.
Camera position¶
The Mappls Maps SDK for Android gives you full control over the map camera's position and behavior, enabling you to create highly customized and interactive map experiences. The camera is defined by several key properties:
-
target
: The geographic coordinates (latitude and longitude) that the camera focuses on. -
bearing
: The map’s rotation, representing the direction the camera is facing. A bearing of 0° points north, while increasing values rotate the map clockwise to indicate a different orientation. -
tilt
: The angle between the camera and the ground plane. A tilt of 0° provides a top-down view, while higher values (e.g., 60°) offer a more angled, horizon-facing perspective. -
zoom
: Controls how close the camera is to the map content. Lower zoom levels (e.g., 1) show large areas like continents, mid-range values (e.g., 11) show city-level detail, and higher zoom levels reveal streets, buildings, and points of interest. -
padding
: Specifies the insets from the map's edges, affecting where the target appears within the visible viewport. Padding is useful for adjusting camera focus without moving the map center visually.
Set the Camera Position on Map¶
- Using
setCameraPosition
#### Kotlin
val cameraPosition = CameraPosition.Builder().tilt(0.0).zoom(3.0).target(LatLng(28.61, 77.23)).build()
mapplsMap.cameraPosition = cameraPosition
#### Java
CameraPosition cameraPosition = new CameraPosition.Builder().zoom(3.0).bearing(0.0).tilt(0.0).target(new LatLng(28.61, 77.23)).build();
mapplsMap.setCameraPosition(cameraPosition);
- Using
moveCamera
oranimateCamera
oreaseCamera
#### Kotlin
val cameraPosition = CameraPosition.Builder().tilt(0.0).zoom(3.0).target(LatLng(28.61, 77.23)).build()
mapplsMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
#### Java
CameraPosition cameraPosition = new CameraPosition.Builder().zoom(3.0).bearing(0.0).tilt(0.0).target(new LatLng(28.61, 77.23)).build();
mapplsMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
Camera Animations¶
Mappls Map's SDK support three types of Animations: - Move Camera - Ease Camera - Animate Camera
Move Camera¶
This method immediately updates the map to the specified CameraPosition without applying any transition or animation, functioning similarly to setCameraPosition
:
Kotlin¶
mapplsMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
Java¶
mapplsMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
Ease Camera¶
This method transitions the map to the provided CameraPosition with a grounded animation, offering a smooth and immersive camera movement experience.
Kotlin¶
mapplsMap.easeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
Java¶
mapplsMap.easeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
Animate Camera¶
This method transitions the map to the specified CameraPosition with a flight animation, simulating a smooth, high-altitude movement for a more dynamic visual experience.
Kotlin¶
mapplsMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
Java¶
mapplsMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
Note: When using
easeCamera
andanimateCamera
, you need to wait until the camera movement is complete before calling new camera control functions. To detect when the camera movement finishes, you can useCancelableCallback
.
Kotlin¶
mapplsMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), object: MapplsMap.CancelableCallback {
override fun onCancel() {
// Cancel Due to other camera movement invoke
}
override fun onFinish() {
// Finish camera movement
}
})
Java¶
mapplsMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), new MapplsMap.CancelableCallback() {
@Override
public void onCancel() {
// Cancel Due to other camera movement invoke
}
@Override
public void onFinish() {
// Finish camera movement
}
});
Map SDK support : More Controls on Camera Here
For any queries and support, please contact:
Email us at apisupport@mappls.com
Support
Need support? contact us!