zoomAround method

void zoomAround(
  1. dynamic position,
  2. double zoom
)

Implementation

void zoomAround(dynamic position, double zoom) {
  UPoint halfSize = UPoint.from(_halfSize);
  UPoint containerPoint;

  double scale = getZoomScale(zoom);

  if (position is UPoint) {
    containerPoint = position;
  } else if (position is LatLng) {
    containerPoint = latlngToPoint(position);
  } else {
    position = LatLng.from(position);
    containerPoint = latlngToPoint(position);
  }

  UPoint offset = (containerPoint - halfSize) * (1 - (1 / scale));
  LatLng? center = pointToLatLng(halfSize + offset);
  move(center, zoom);
}