You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @sheley1998. As you've discovered, calling setZoom first is the solution. The reason that order matters in this case is that when the map is zoomed out, the center location is constrained by the fact that we don't want to have blank space at the top or bottom of the map view. Thus setCenter is not guaranteed to set the center latitude to the value provided. When the map is zoomed in, this isn't an issue.
Eventually we're planning to remove setCenter and setZoom in favor of an API where you provide all desired camera settings in a single call (#2801). That will avoid this issue.
mapbox-gl-js version:
Steps to Trigger Behavior
var map = new mapboxgl.Map
({
container: 'somecontainer',
style: 'mapbox://styles/mapbox/streets-v9'
});
map.setCenter([121.472644, 31.231706]);
map.setZoom(10);
Expected Behavior
Map should be centered in Shanghai
Actual Behavior
Map centers near an Indonesian island called Tumbulawa
Fix (Hack?)
Calling setZoom before setCenter fixes this problem
The text was updated successfully, but these errors were encountered: