问题
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