谷歌地图API缩放范围 [英] google map API zoom range

查看:327
本文介绍了谷歌地图API缩放范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用谷歌地图API版本3,我试着用不同的缩放值,我随机做了一些数字,从1开始到100,地图获取的数字越来越多,但一些级别给出了相同的结果,我的意思是



我想知道,缩放的确切范围是什么?

解决方案

可用缩放级别



缩放级别0是缩放级别最大的缩放级别,视图的X和Y范围,并将线性分辨率加倍。



Google地图建立在256x256像素图块系统上,其中缩放级别0是图片的256x256像素图片整个地球。缩放级别为1的256x256拼图可将缩放级别为0的128x128像素区域放大。

正如bkaid所述,可用的缩放范围取决于您所看的位置以及


  • 路线图 - 无处不在缩放级别22

  • 混合和卫星地图 - 最大可用缩放级别取决于位置。以下是一些例子:


    • 南极的偏远地区:13

    • 戈壁沙漠:17

    • 美国和欧洲的大部分地区:21

    • 深度缩放位置:22-23(请参阅 bkaid's link




请注意,这些值适用于 Google Static Maps API ,这似乎比JavaScript API提供了更多的缩放级别。看起来,静态地图可用的额外缩放级别只是来自Javascript API的最高分辨率图像的上采样版本。



缩放级别



Google地图使用墨卡托投影,因此比例因纬度而异。计算基于纬度的正确比例的公式为:
$ b $ p $ meter_per_pixel = 156543.03392 * Math.cos(latLng.lat()* Math.PI / 180)/ Math.pow(2,缩放)



公式来自 Chris Broadfoot的评论


I am using google map API version-3 , I was trying with different zoom value, I have randomly done for some numbers started with 1 upto 100 , map gets zoom in for increasing numbers but some level giving same result, I mean I am getting same zoom for 30 and 100.

I like to know , what is the exact range for zoom?

解决方案

Available Zoom Levels

Zoom level 0 is the most zoomed out zoom level available and each integer step in zoom level halves the X and Y extents of the view and doubles the linear resolution.

Google Maps was built on a 256x256 pixel tile system where zoom level 0 was a 256x256 pixel image of the whole earth. A 256x256 tile for zoom level 1 enlarges a 128x128 pixel region from zoom level 0.

As correctly stated by bkaid, the available zoom range depends on where you are looking and the kind of map you are using:

  • Road maps - seem to go up to zoom level 22 everywhere
  • Hybrid and satellite maps - the max available zoom levels depend on location. Here are some examples:
    • Remote regions of Antarctica: 13
    • Gobi Desert: 17
    • Much of the U.S. and Europe: 21
    • "Deep zoom" locations: 22-23 (see bkaid's link)

Note that these values are for the Google Static Maps API which seems to give one more zoom level than the Javascript API. It appears that the extra zoom level available for Static Maps is just an upsampled version of the max-resolution image from the Javascript API.

Map Scale at Various Zoom Levels

Google Maps uses a Mercator projection so the scale varies substantially with latitude. A formula for calculating the correct scale based on latitude is:

meters_per_pixel = 156543.03392 * Math.cos(latLng.lat() * Math.PI / 180) / Math.pow(2, zoom)

Formula is from Chris Broadfoot's comment.

这篇关于谷歌地图API缩放范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆