applyCameraDelta method

Future<CommandCompletion> applyCameraDelta(
  1. CameraDelta delta
)

Moves the camera relative to where it is, as a gesture does.

delta can pan the map's content by an offset on the screen, scale the zoom, and add to the bearing and pitch. An anchor keeps one screen point in place while the scale, bearing, or pitch changes. An anchor needs one of those changes, and combines with an offset only when the delta has no animation. The function finishes when the map applies the delta, before an animation ends.

A delta that replaces an animated one starts from where that animation left the camera, so the rest of the replaced change never happens. To reach an exact camera, use MapHandle.updateCamera().

A delta in the end phase can carry momentum, which keeps the camera moving from the gesture's release velocities and slows it on each rendered frame. The gesture lasts until the momentum ends: the snapshot keeps gesture_in_progress set, and camera events report CameraChangeSource.momentum. With momentum, animation sets only transition_id and the end handler, which runs when the gesture ends.

A delta in the begin phase, MapHandle.cancelCameraTransitions(), or a cancellation by that ID stops the momentum. A later command that sets a field stops only the parts of the momentum that move that field. On a tilted map, the pan moves the map's content the same distance on the screen in every direction.

See mln_map_apply_camera_delta in the C API reference.

Implementation

Future<CommandCompletion> applyCameraDelta(CameraDelta delta) =>
    _command((arena, completion) {
      final registrations = _NativeRegistrations(_callbackRoots);
      return registrations.run(
        () => raw.mln_map_apply_camera_delta(
          _handle.raw,
          _writeCameraDelta(delta, arena, registrations),
          completion,
          nativeDiagnostic,
        ),
      );
    });