Skip to content

Instantly share code, notes, and snippets.

@Coinhunter
Created March 13, 2014 17:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Coinhunter/9533345 to your computer and use it in GitHub Desktop.
int mZoomLevel = mapView.getZoomLevel();
final double maxZoomLatitudeSpan = mZoomLevel == guide.getMap().getMaxZoom() ?
mapView.getBoundingBox().getLatitudeSpanE6() :
mapView.getBoundingBox().getLatitudeSpanE6() / Math.pow(2, guide.getMap().getMaxZoom() - mZoomLevel);
final double requiredLatitudeZoom =
guide.getMap().getMaxZoom() -
Math.ceil(Math.log(box.getLatitudeSpanE6() / maxZoomLatitudeSpan) / Math.log(2));
final double maxZoomLongitudeSpan = mZoomLevel == guide.getMap().getMaxZoom() ?
mapView.getBoundingBox().getLongitudeSpanE6() :
mapView.getBoundingBox().getLongitudeSpanE6() / Math.pow(2, guide.getMap().getMaxZoom() - mZoomLevel);
final double requiredLongitudeZoom =
guide.getMap().getMaxZoom() -
Math.ceil(Math.log(box.getLongitudeSpanE6() / maxZoomLongitudeSpan) / Math.log(2));
int newMinZoom = (int)(requiredLatitudeZoom < requiredLongitudeZoom ? requiredLatitudeZoom : requiredLongitudeZoom);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment