0
我希望根據縮放級別以米或公里計算半徑。按縮放級別改變半徑
我發現這個公式 - 這使我每個像素的粗略計算米: https://groups.google.com/forum/#!topic/google-maps-js-api-v3/hDRO4oHVSeM
而且,這些鏈接幫助我理解我試圖完成準確: google map API zoom range How to get center of map for v2 android maps?
這是實現:
double calculateScale(float zoomLevel, LatLng centerPos){
double meters_per_pixel = 156543.03392 * Math.cos(centerPos.latitude * Math.PI/180)/Math.pow(2, zoomLevel);
return meters_per_pixel;
}
這就是我如何聽縮放級別變化:
_map.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() {
@Override
public void onCameraIdle() {
Log.d(Consts.TAGS.FRAG_MAIN_MAP,"Current Zoom : " + _map.getCameraPosition().zoom);
Log.d(Consts.TAGS.FRAG_MAIN_MAP,"Center Lat : " + _map.getCameraPosition().target.latitude +
", Center Long : " + _map.getCameraPosition().target.longitude);
}}
現在,每當用戶改變縮放級別,我想,以確定哪些是可以在地圖視圖中顯示的最大半徑...
這個答案告訴我如何以適合我的用例(我用地圖容器佈局而不是_map)的方式計算最大半徑。 – lionheart
對不起,我用了太多細節。主要觀點是獲得一半的視角,它將是maxRadius。 :)很高興你明白了這一點。 –