Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change transformation setters call order #2391

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oxidase
Copy link

@oxidase oxidase commented May 15, 2024

The order of setters in applyViewStateToTransform has a side effect which leads to wrong camera transformation. In a case of map.jumpTo({center: [12,34], zoom: 15}) from {center: [0,0], zoom: 0} the current order of setters in case of maplibre-gl leads to the following:

tr.center = new center.constructor(v.longitude, v.latitude);  /* (12, 34); */
  -> const {center, zoom} = this.getConstrained(this.center /* [12, 34]*/ , this.zoom /* 0 */);
       this.center = center;  /* [12, 0] */
       this.zoom = zoom;  /* 0 */

tr.zoom = v.zoom; /* 15 */
  -> const {center, zoom} = this.getConstrained(this.center /* [12, 0]*/ , this.zoom /* 15 */);
       this.center = center;  /* [12, 0] */
       this.zoom = zoom;  /* 15 */

But expected would be to have {center: [12,34], zoom: 15} instead of {center: [12,0], zoom: 15}.

The changed order leads to the following setters sequence

tr.zoom = v.zoom; /* 15 */
  -> const {center, zoom} = this.getConstrained(this.center /* [0, 0]*/ , this.zoom /* 15 */);
       this.center = center;  /* [0, 0] */
       this.zoom = zoom;  /* 15 */

tr.center = new center.constructor(v.longitude, v.latitude);  /* (12, 34); */
  -> const {center, zoom} = this.getConstrained(this.center /* [12, 34]*/ , this.zoom /* 15 */);
       this.center = center;  /* [12, 34] */
       this.zoom = zoom;  /* 15 */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant