zoom method

  1. @override
double zoom(
  1. double scale
)
override

Scale to Zoom function.

Implementation

@override
double zoom(double scale) {
  // Find closest number in _scales, down
  final downScale = _closestElement(_scales, scale);
  if (downScale == null) {
    return double.negativeInfinity;
  }
  final downZoom = _scales.indexOf(downScale);
  // Check if scale is downScale => return array index
  if (scale == downScale) {
    return downZoom.toDouble();
  }
  // Interpolate
  final nextZoom = downZoom + 1;
  final nextScale = _scales[nextZoom];

  final scaleDiff = nextScale - downScale;
  return (scale - downScale) / scaleDiff + downZoom;
}