zoom method

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

Scale to Zoom function.

Implementation

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

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