cameraForTile function

CameraOptions cameraForTile(
  1. CanonicalTileId tile,
  2. LogicalSize logicalSize
)

Computes the camera that shows exactly one tile on a square map.

Jump a map in MapMode.tile to the camera to render tile, where logicalSize is the map's size. The camera centers the tile, zooms until the tile fills the map, and looks straight down with north up and no padding. The map keeps its camera within its zoom limits, so for a deep tile, raise the maximum zoom past the camera's with MapHandle.setBounds().

See mln_camera_for_tile in the C API reference.

Errors:

  • Status.invalidArgument when logicalSize isn't square, or is wider than 512 pixels. For denser tiles, raise the map's scale factor instead.
  • Status.invalidArgument when tile.x or tile.y isn't less than 2 to the power tile.z, or when the tile can't fill the map at a zoom from 0 to 25.5, as for tile 0/0/0 on a 256-pixel map.

Implementation

CameraOptions cameraForTile(CanonicalTileId tile, LogicalSize logicalSize) =>
    withNativeArena((arena) {
      ensureAbiVersion();
      final outCamera = arena<raw.mln_camera_options>();
      outCamera.ref.size = sizeOf<raw.mln_camera_options>();
      _check(
        raw.mln_camera_for_tile(
          _writeCanonicalTileId(tile, arena).ref,
          _writeLogicalSize(logicalSize, arena).ref,
          outCamera,
          nativeDiagnostic,
        ),
      );
      return _readCameraOptions(outCamera.ref);
    });