Google静态地图尺寸偏差 [英] Google Static Maps Dimension Discrepancy

查看:188
本文介绍了Google静态地图尺寸偏差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用这个问题的答案中显示的代码:

Google Maps V3 - 如何计算给定范围的缩放比例



但我似乎无法让我的静态地图正确排列。



在这个链接中,我可以正确计算宽度,但不能计算高度。

http://maps.googleapis.com/maps/api/staticmap?center=30.42997,-91.179745&zoom=11&size=500x600&scale=1&format=png32&maptype=roadmap& sensor = false



从早前的SO帖子看,身高应该是

size * 360/256/2 ^ Zoom



所以我们插入...

600 * 360/256/2 ^ 11 = 0.41199

这意味着我们期望图像的最高纬度位于 30.42997 +(0.41199 / 2)= 30.63596 。但是,当您在Google地图上绘制该纬度并缩放到相同的缩放级别时,该点会比我们的图像所接收的要高得多。



有关我如何计算Google发回的图片高度的任何想法?

解决方案

纬度有180度,而不是360度,所以身高的计算应该是 $ b

  height * 180/256/2 ^放大


I've been using the code shown in the answer to this question:

Google Maps V3 - How to calculate the zoom level for a given bounds

but I can't seem to get my static maps to line up correctly.

In this link, I can calculate the width correctly, but not the height.

http://maps.googleapis.com/maps/api/staticmap?center=30.42997,-91.179745&zoom=11&size=500x600&scale=1&format=png32&maptype=roadmap&sensor=false

From the SO post earlier, the height should be

size * 360 / 256 / 2^Zoom

so we plug in...

600 * 360 / 256 / 2^11 = 0.41199

This means that we expect top latitude of the image to be at 30.42997 + (0.41199 / 2) = 30.63596. But when you plot that latitude on Google Maps and zoom to the same zoom level, the point is much higher than what our image is receiving.

Any ideas on how I can calculate the height of the image that Google is sending back?

解决方案

There are 180 degrees in latitude, not 360, so the height calculation shall be

height * 180 / 256 / 2^Zoom

这篇关于Google静态地图尺寸偏差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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