谷歌地图v3:边界的中心不同于地图的中心 [英] google maps v3: center of bounds is different from center of the map

查看:75
本文介绍了谷歌地图v3:边界的中心不同于地图的中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

map.getCenter()可能不同于 map.getBounds()。getCenter()

 > cragMap.getCenter()
> Q {d:13.823563748466814,e:0,toString:function,b:function,equals:function ...}
> cragMap.getBounds()。getCenter()
> Q {d:5.9865924355766005,e:0,toString:function,b:function,equals:function ...}



<这发生在我的情况,并防止我编写一个特定的功能。任何想法是什么原因造成的?

解决方案

这是由mercartor投影的纬度非线性造成的。 map.getBounds()。getCenter()返回latDim和lngDim的平均值。但是平均值通常与地图中心不同,因为北部和南部的纬度范围会发生变化。

How is it possible that map.getCenter() might be different from map.getBounds().getCenter()?

> cragMap.getCenter()
> Q {d: 13.823563748466814, e: 0, toString: function, b: function, equals: function…}
> cragMap.getBounds().getCenter()
> Q {d: 5.9865924355766005, e: 0, toString: function, b: function, equals: function…}

This happens in my case and prevents me from coding one particular feature. Any idea what is the cause of this?

解决方案

It is caused by latitude non-linearity of mercartor projection. map.getBounds().getCenter() returns average of latDim and lngDim. But that average is usually different from the center of the map because to the north and south the scale of latitude changes.

这篇关于谷歌地图v3:边界的中心不同于地图的中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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