近期基於高德地圖進行了很多開發工做,期間遇到了一個與比例尺相關的問題。html
如何將地圖比例尺與高德地圖中的縮放級別(0-20)對應起來?api
[高德地圖api比例尺][https://www.cnblogs.com/yesyes/p/6785705.html]code
高德地圖中的zoom是一個float類型的參數,取值範圍爲(0-20),此處沒有作到精細化轉換,待後續更新!htm
/** * 「scale-zoom」映射關係:https://www.cnblogs.com/yesyes/p/6785705.html * * @param scale 比例尺 * @return zoom值 */ private int scale2Zoom(int scale) { if (scale <= 10) return 19; else if (scale <= 25) return 18; else if (scale <= 50) return 17; else if (scale <= 100) return 16; else if (scale <= 200) return 15; else if (scale <= 500) return 14; else if (scale <= 1000) return 13; else if (scale <= 2000) return 12; else if (scale <= 5000) return 11; else if (scale <= 10000) return 10; else if (scale <= 20000) return 9; else if (scale <= 30000) return 8; else if (scale <= 50000) return 7; else if (scale <= 100000) return 6; else if (scale <= 200000) return 5; else if (scale <= 500000) return 4; else if (scale <= 1000000) return 3; else if (scale > 1000000) return 2; return 20; }