MapCameraState

A snapshot of the map camera.

An immutable value type on purpose — MapLibre's CameraPosition carries fields this SDK does not expose (altitude, roll, field of view, padding), so equality and change detection on it are unreliable.

Two states are equal when they frame the same view of the world, and that takes two departures from a data class's generated equality — which is why equals/hashCode/copy are hand-written here, the same reasoning as com.getwemap.sdk.core.model.entities.Coordinate:

  • lastChangeReason is excluded, because why the camera moved does not change where it is. A camera the integrator builds has no reason and the map always reports one, so including it would make every update compare unequal.

  • The scalars are compared with a small epsilon. MapLibre round-trips a camera through its own math, so one you apply comes back a few ULPs off — apply a bearing of 30.0 and the map reports 29.999999999999996. Under exact equality the camera you set would never equal the camera the map reports.

Together, those are what let a two-way camera state recognise its own value instead of re-applying it in a loop. hashCode uses the exact values and is therefore not consistent with equals — the same deliberate trade-off Coordinate makes.

Constructors

Link copied to clipboard
constructor(center: LatLng, zoom: Double, bearing: Double = 0.0, pitch: Double = 0.0)

Creates a camera state.

Properties

Link copied to clipboard

The heading of the map, in degrees clockwise from true north.

Link copied to clipboard
val center: LatLng

The geographic coordinate at the center of the map.

Link copied to clipboard

What caused the most recent change — distinguishes a user pan from a programmatic move.

Link copied to clipboard

The pitch of the camera, in degrees from a top-down orientation. MapLibre calls this the tilt.

Link copied to clipboard

The zoom level of the map.

Functions

Link copied to clipboard
fun copy(center: LatLng = this.center, zoom: Double = this.zoom, bearing: Double = this.bearing, pitch: Double = this.pitch): MapCameraState

Returns a copy of this state with the given fields replaced.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun toCameraPosition(): CameraPosition

Converts to a MapLibre camera.

Link copied to clipboard
open override fun toString(): String