Not sure if this is a bug or if I'm missing something basic here. The docs certainly don't clarify anything in this regard. I was told that these values should be the same if I haven't set the other camera properties like tilt/rotation - which I haven't. Upon instantiating the map, for more zoomed in views like zoomLevel 9 etc, the lat values are the same. For more zoomed out views like zoomLevel 4, the lat values differ by a significant amount. The longitudes always match.
Here is a jsbin:
https://jsbin.com/ligipawoke/2/edit?html,console,output
The docs say:
map.getCenter(): Returns the map's geographical centerpoint.
map.getBounds(): Returns the map's geographical bounds.
bounds.getCenter(): Returns the geographical coordinate equidistant from the bounding box's corners.
This is expected behavior. map.getCenter().lat calculates the center of the map in screen coordinates, then converts that to geographical coordinates by applying the inverse of the Web Mercator projection. map.getBounds().getCenter().lat converts the corners of the map to geographic coordinates using the same formula, then finds the midpoint in both axes. But because the relationship between projected and unprojected latitudes is not linear in Web Mercator (and in Mercator projections in general), these are not the same value. Mercator projections "stretch" distances in the north-south direction the further you get from the equator.
John, thanks for the explanation.
Most helpful comment
This is expected behavior.
map.getCenter().latcalculates the center of the map in screen coordinates, then converts that to geographical coordinates by applying the inverse of the Web Mercator projection.map.getBounds().getCenter().latconverts the corners of the map to geographic coordinates using the same formula, then finds the midpoint in both axes. But because the relationship between projected and unprojected latitudes is not linear in Web Mercator (and in Mercator projections in general), these are not the same value. Mercator projections "stretch" distances in the north-south direction the further you get from the equator.