1

I have a mapview when the user click on the mapview it set the lon & the lat points. I want to be able to capture the zoom level / radius in distance of the zoom what is the best way to do this?

user546683
  • 21
  • 3
  • Please check this question: http://stackoverflow.com/questions/6002563/android-how-do-i-set-the-zoom-level-of-map-view-to-1-km-radius-around-my-curren Worked fine for me. – ahsanul_k Jul 16 '12 at 12:26

2 Answers2

2

Please check this question: Android: How do I set the zoom level of map view to 1 km radius around my current location?

Worked fine for me.

You have to use:

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

mapView.getController().setZoom(calculateZoomLevel(metrics.widthPixels));




private int calculateZoomLevel(int screenWidth) {
    double equatorLength = 40075004; // in meters
    double widthInPixels = screenWidth;
    double metersPerPixel = equatorLength / 256;
    int zoomLevel = 1;
    while ((metersPerPixel * widthInPixels) > 1000) {
        metersPerPixel /= 2;
        ++zoomLevel;
    }
    return zoomLevel;
}
Community
  • 1
  • 1
ahsanul_k
  • 161
  • 8
0

getZoomLevel() is the method you are looking for.

Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148