handleScaleUpdate method

void handleScaleUpdate(
  1. ScaleUpdateDetails details
)

Implementation

void handleScaleUpdate(ScaleUpdateDetails details) {
  if (_tapUpCounter == 1) {
    _handleDoubleTapHold(details);
    return;
  }

  setState(() {
    final focalOffset = _offsetToPoint(details.localFocalPoint);

    ///  Added to restrict zoom out & in
    var newZoom = map!.zoom;
    if ((!((map!.zoom <= 2) &&
            (_getZoomForScale(_mapZoomStart, details.scale) <= 2))) &&
        (!((map!.zoom >= 18) &&
            (_getZoomForScale(_mapZoomStart, details.scale) >= 18)))) {
      newZoom = _getZoomForScale(_mapZoomStart, details.scale);
    } // for zoom out & in

    //
    // final newZoom = _getZoomForScale(_mapZoomStart, details.scale);
    final focalStartPt = map!.project(_focalStartGlobal, newZoom);
    final newCenterPt = focalStartPt - focalOffset + map!.size! / 2.0;
    final newCenter = map!.unproject(newCenterPt, newZoom);
    map!.move(newCenter, newZoom, hasGesture: true);
    _flingOffset = _pointToOffset(_focalStartLocal - focalOffset);
  });
}