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?
Asked
Active
Viewed 1,136 times
1
-
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 Answers
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;
}
0
getZoomLevel()
is the method you are looking for.

Nikola Despotoski
- 49,966
- 15
- 119
- 148
-
zoom level get the zoom level . how you get the radius in miles/meters – user546683 Jul 30 '11 at 15:58