Google地图:如何计算“双倍”缩放级别? [英] Google Maps: how to calculate the "double" the zoom level?
问题描述
是解决我的问题的好主意。
现在,问题是:我如何计算双倍缩放级别?
编辑
含义:
地图正在查看2 x 2公里的平方,我想缩小以查看4 x 4平方公里的正方形。
执行 newZoom = oldZoom * 2
不起作用: - (((
缩放级别的每个增量都会使缩放倍数增加一倍。
newZoom = oldZoom-1;
从文档 :
世界坐标反映给定投影的绝对位置,但我们需要将它们转换为像素坐标以确定给定缩放的像素偏移量这些像素坐标是使用以下公式计算的:
pixelCoordinate = worldCoordinate * 2 zoomLevel
从上面的公式可以看出,每个增加的缩放级别在x和y方向都是两倍。因此,每个较高的缩放级别包含比前一级别高四倍的分辨率。例如,在缩放级别1时,地图由4个256x256像素拼贴组成,从而产生512x512的像素空间。在缩放级别19时,地图上的每个x和y像素都可以使用介于0和256 * 219之间的值进行引用
is a good idea for solving my problem.
Now, the problem is: how do I calculate "double" the zoom level?
EDIT
Meaning:
the map is looking at a square 2x2 km, I want to zoom out to look at a 4x4 km square.
Doing newZoom=oldZoom*2
does not work :-(((
Each increment of the zoom level doubles the scale. To zoom out by a factor of two, add one to the zoom level.
newZoom=oldZoom-1;
World coordinates reflect absolute locations on a given projection, but we need to translate these into pixel coordinates to determine the "pixel" offset at a given zoom level. These pixel coordinates are calculated using the following formula:
pixelCoordinate = worldCoordinate * 2 zoomLevel
From the above equation, note that each increasing zoom level is twice as large in both the x and y directions. Therefore, each higher zoom level contains four times as much resolution as the preceding level. For example, at zoom level 1, the map consists of 4 256x256 pixels tiles, resulting in a pixel space from 512x512. At zoom level 19, each x and y pixel on the map can be referenced using a value between 0 and 256 * 219
这篇关于Google地图:如何计算“双倍”缩放级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!