{"action":"created","issue":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/5345","repository_url":"https://api.github.com/repos/mapbox/mapbox-gl-js","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/5345/labels{/name}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/5345/comments","events_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/5345/events","html_url":"https://github.com/mapbox/mapbox-gl-js/issues/5345","id":259742124,"number":5345,"title":"setCenter doesn't work when called before setZoom","user":{"login":"sheley1998","id":3954635,"avatar_url":"https://avatars1.githubusercontent.com/u/3954635?v=4","gravatar_id":"","url":"https://api.github.com/users/sheley1998","html_url":"https://github.com/sheley1998","followers_url":"https://api.github.com/users/sheley1998/followers","following_url":"https://api.github.com/users/sheley1998/following{/other_user}","gists_url":"https://api.github.com/users/sheley1998/gists{/gist_id}","starred_url":"https://api.github.com/users/sheley1998/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sheley1998/subscriptions","organizations_url":"https://api.github.com/users/sheley1998/orgs","repos_url":"https://api.github.com/users/sheley1998/repos","events_url":"https://api.github.com/users/sheley1998/events{/privacy}","received_events_url":"https://api.github.com/users/sheley1998/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-09-22T08:35:42Z","updated_at":"2017-09-22T17:44:41Z","closed_at":"2017-09-22T17:44:41Z","author_association":"NONE","body":"**mapbox-gl-js version**:\r\n\r\n### Steps to Trigger Behavior\r\n\r\nvar map = new mapboxgl.Map\r\n({\r\n    container: 'somecontainer',\r\n    style: 'mapbox://styles/mapbox/streets-v9'\r\n});\r\n\r\nmap.setCenter([121.472644, 31.231706]);\r\nmap.setZoom(10);\r\n\r\n### Expected Behavior\r\nMap should be centered in Shanghai\r\n\r\n### Actual Behavior\r\nMap centers near an Indonesian island called Tumbulawa\r\n\r\n### Fix (Hack?)\r\nCalling setZoom before setCenter fixes this problem"},"comment":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/comments/331514887","html_url":"https://github.com/mapbox/mapbox-gl-js/issues/5345#issuecomment-331514887","issue_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/5345","id":331514887,"user":{"login":"jfirebaugh","id":98601,"avatar_url":"https://avatars2.githubusercontent.com/u/98601?v=4","gravatar_id":"","url":"https://api.github.com/users/jfirebaugh","html_url":"https://github.com/jfirebaugh","followers_url":"https://api.github.com/users/jfirebaugh/followers","following_url":"https://api.github.com/users/jfirebaugh/following{/other_user}","gists_url":"https://api.github.com/users/jfirebaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/jfirebaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfirebaugh/subscriptions","organizations_url":"https://api.github.com/users/jfirebaugh/orgs","repos_url":"https://api.github.com/users/jfirebaugh/repos","events_url":"https://api.github.com/users/jfirebaugh/events{/privacy}","received_events_url":"https://api.github.com/users/jfirebaugh/received_events","type":"User","site_admin":false},"created_at":"2017-09-22T17:44:41Z","updated_at":"2017-09-22T17:44:41Z","author_association":"MEMBER","body":"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.\r\n\r\nEventually 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."}}
{"actor":{"display_login":"jfirebaugh"}}