google maps v3: center of bounds is different from center of the map

…衆ロ難τιáo~ 提交于 2019-12-22 10:56:57

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/21576400/google-maps-v3-center-of-bounds-is-different-from-center-of-the-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!