calculateZoomScale static method

double calculateZoomScale(
  1. double densityDpi,
  2. double zoomLevel,
  3. ILatLng target
)

Implementation

static double calculateZoomScale(double densityDpi, double zoomLevel, ILatLng target) {
  var dpi = densityDpi * 160;

  var mapwidth = 256.0 * math.pow(2, zoomLevel);
  var clipLatitude = math.min(math.max(target.latitude, minLatitude), maxLatitude);
  var angle = clipLatitude * math.pi / 180;
  var angleRadians = angle.radians;
  var groundResolution = (math.cos(angleRadians) * 2 * math.pi * SphericalUtil.earthRadius) / mapwidth;
  var mapScale = (groundResolution * dpi / 0.0254);

  return 1 / mapScale;
}