且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

这个谷歌地图缩放级别计算是如何工作的?

更新时间:2023-01-04 12:59:10

有些数字很容易解释

  • MeanRadiusEarthInKm = 6371 (according to IUGG)

DegToRadDivisor = 180/PI = 57.2958

DegToRadDivisor = 180/PI = 57.2958

再次,缩放级别每一步都将尺寸加倍,即将缩放级别增加屏幕尺寸的一半.

And again the zoom level doubles the size with each step, i.e. increase the zoomlevel by one halfs the size on the screen.

zoom = 8 - log(factor * dist) / log(2) = 8 - log_2(factor * dist)
=> dist = 2^(8-zoom) / factor

从数字中我们发现缩放级别 8 对应的距离为 276.89 公里.

From the numbers we find that zoom level eight corresponds to a distance of 276.89km.