getZoomFromMaxVisibleTile function

double getZoomFromMaxVisibleTile(
  1. BuildContext context,
  2. double tileSize,
  3. int maxTile, {
  4. Orientation? orientation,
})

Implementation

double getZoomFromMaxVisibleTile(
  BuildContext context,
  double tileSize,
  int maxTile, {
  Orientation? orientation,
}) {
  final screenSize = MediaQuery.of(context).size;
  if (screenSize == Size.zero || screenSize == Size.infinite) {
    return 1;
  }
  double maxSize = 0;
  switch (orientation) {
    case Orientation.portrait:
      maxSize = screenSize.height;
      break;
    case Orientation.landscape:
      maxSize = screenSize.width;
      break;
    default:
      maxSize = max(screenSize.width, screenSize.height);
  }
  return maxSize / (tileSize * maxTile);
}