/** * 將實際地理距離轉換爲屏幕像素值 * * @param distance * 實際距離,單位爲米 * @param currScale * 當前地圖尺寸 * @param context * @return */ public static double metreToScreenPixel(double distance, double currScale, Context context) { float dpi = context.getResources().getDisplayMetrics().densityDpi; // 當前地圖範圍內1像素表明多少地圖單位的實際距離 double resolution = (25.39999918 / dpi) * currScale / 1000; return distance / resolution; } /** * 將屏幕上對應的像素距離轉換爲當前顯示地圖上的地理距離(米) * * @param pxlength * @param currScale * @param context * @return */ public static double screenPixelToMetre(double pxlength, double currScale, Context context) { float dpi = context.getResources().getDisplayMetrics().densityDpi; double resolution = (25.39999918 / dpi) * currScale / 1000; return pxlength * resolution; }
來自:http://blog.csdn.net/u012481275/article/details/12861179spa