I've the radius calculated by the following formula:
public double getRadius() {
double latitudeSpan = 0;
VisibleRegion vr = mapView.getProjection().getVisibleRegion();
float [] results = new float[3];
Location.distanceBetween(vr.farLeft.latitude, vr.farLeft.longitude, vr.farRight.latitude, vr.farRight.longitude, results);
latitudeSpan = results[0];
return latitudeSpan;
}
but now I want to set the same zoom level using this radius later. I calculated the zoom level by using this formula:
public static float zoom(double distance, Activity ctx) {
byte zoom = 1;
WindowManager windowManager = (WindowManager) ctx.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
int widthInPixels = windowManager.getDefaultDisplay().getWidth();
double equatorLength = 6378136.28;//in meters
double metersPerPixel = equatorLength / 256;
while ((metersPerPixel * widthInPixels) > distance) {
metersPerPixel /= 2;
++zoom;
}
if (zoom > 21)
zoom = 21;
if (zoom < 1)
zoom = 1;
return zoom;
}
But instead of getting zoom level in integer, how could I found the exact zoom level (in float) that was previously. Could any one help me please?