【发布时间】:2014-03-19 09:30:11
【问题描述】:
我想以英里为单位设置谷歌地图的缩放级别, 现在,我正在使用这段代码,但我认为它是错误的,需要改进。
map.animateCamera(CameraUpdateFactory.newLatLngZoom(MYLOC, calculateZoomLevel()));
public byte calculateZoomLevel() {
byte zoom = 1;
// if distance is in KMs
double E = 40075;
// if distance is in Miles
//double E = 21638;
zoom = (byte) Math.round(Math.log(E / nearByRadius) / Math.log(2) + 1);
// to avoid exeptions
if (zoom > 21) {
zoom = 21;
}
if (zoom < 1) {
zoom = 1;
}
Log.v(TAG, "zoom level = " + zoom);
return zoom;
}
【问题讨论】:
-
您找到解决方案了吗?因为我也有同样的要求..
标签: android google-maps google-maps-api-2