0
我想将Google地图的缩放级别设置为英里, 现在,我正在使用此代码,但我认为这是错误的,需要改进。Android Google Maps v2以英里为单位设置缩放级别
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;
}
你得到了这个解决办法吗?因为我也有相同的要求。 –