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;
}
你得到了這個解決辦法嗎?因爲我也有相同的要求。 –