0

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?

Pankaj
  • 833
  • 12
  • 35
  • I'm trying to achieve the same, did you make any progress? – Litus Mar 19 '15 at 20:33
  • Hi Litus, Didn't get any solution. To overcome this issue, showing a help text below the mapview that visible map area is approx. Thanks – Pankaj Mar 20 '15 at 09:55
  • I found some solutions, here is one: http://stackoverflow.com/questions/6224671/mkcoordinateregionmakewithdistance-equivalent-in-android/16417396#16417396 – Litus Mar 20 '15 at 17:03

0 Answers0